Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Dynamic Portal Filtering--account for no records (showing)

Featured Replies

Hello Forum:

I portion of my database is using the "Dynamically Filtering Filtered Portals" by Sara Severson found on the Soliant Consulting website (for some reason I can't paste a link).

What I was hoping to accomplish was as the user (me only) was typing, the list filters down.  This works fine.  But if I type to the point where the portal goes blank (no records match), then I would like to allow the user the option of creating a new record. 

I attached the sample file.  For simplicity's sake, I stripped out all parts of the DB except that related to this topic.

U/N admin

P/W 1234

The script affecting the portal filtering is at the bottom of Manage Scripts, and the portion I was hoping for some guidance is commented out at the bottom.

Any help or recommendations are always greatly appreciated.

Thanks

Steve

 

As soon as I figure out how to upload the file, I will update.  Currently I get a message saying "Error You aren't permitted to upload this kind of file"  which is of course a FM file.

Sample1.zip

You have to Zip the file.

  • Author

What a brain fart!  Thanks Bruce...file attached.

The script affecting the portal filtering is at the bottom of Manage Scripts, and the portion I was hoping for some guidance is commented out at the bottom.

 

Steve –

 

you haven't really said what your issue is …

 

If it is detecting at what point the filter term doesn't yield any results (i.e. the portal is empty), I suggest the usual “count rows in a filtered portal” trick:

 

Create a summary count field in the target table, or just an unstored calculation field defined as Get ( FoundCount ); put that into a one-row portal with the same filter calculation, give it an object name, and use 

If [ not GetLayoutObjectAttribute ( "theObjectName" ; "content" ) // i.e. = 0 ]
  # Show Custom Dialog etc.
End If

You can place that portal outside of the layout area.

 

btw, since you already have a finely targeted refresh mechanism in place, you can do without the rather blunt instrument of Refresh Window [ Flush … ].

  • Author

Thanks as always Eos, many fine recommendations to try.

I did take the 'blunt instrument' out in my working database.

The 'issue' isn't really an issue per se.  When typing leaves the portal blank (no record, so I'll need to add a new one) I wanted something to trigger a custom dialog with...."No products. Create a new Product record?"..kinda thing.  I will try your suggestions.  The 'count rows in a filtered portal' trick was what I started with, but didn't get it working, because I didn't know the 'trick'. 

However the only problem I see if/when I do get it working is that a simple typo will be annoying with a pop up Show Dialog.  Maybe I'm better off just putting a button to add a new Product record and be done with it.

But I still will try your suggestions first, especially for the learning experience. :grad:

Thanks again for your time.

Steve

However the only problem I see if/when I do get it working is that a simple typo will be annoying with a pop up Show Dialog

 

One man's typo is another man's multi-million dollar brand name … but you're right, that kind of attention will get old pretty quickly.

 

The 'count rows in a filtered portal' trick was what I started with, but didn't get it working, because I didn't know the 'trick'.

 

Interesting … how could you start with it without knowing it …?  :laugh:

 

Anyway, this is the same “trick” that allows you to display a count of portal records; so you may opt to not “hide” the portal, but show it as a “Found records: #” display, regardless of its usage (or not) as “no matches detector”.

  • Author

Well I didn't know 'the trick' but I was trying different options with Get(FoundCount) and counting portal rows......but having an idea and guessing didn't work out for me.

Thanks again :)

 

Note that you don't need a separate portal for this. If one of the fields in the filtered portal will alway have a value, you can test this.

See attached.

 

I am checking for whether the Category field in the portal is empty.

However, since you have set that field to act as a buttons, I had to first ungroup it, give an object name to the field itself, then change it back into a button.

 

SampleMOD.fmp12.zip

  • Author

Wow thanks Bruce. Works perfectly.  I read about GetLayoutObjectAttribute in the help section even after your example but would never figure out how it would work, without your solution

Thanks again for taking the time to help and teach.

 

Steve

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.