Over 46,000+ Business Solution Developers Find answers, ask questions, and connect with our community of business solutions developers, business owners and partners.
Creating a Filtered Portal with Find – FileMaker Today
Here is a real slick tip on portals and portal navigation from our affilate Bob Patin at Longterm Soultions. A common user interface these days is a layout where there is a list of records on the left side; clicking on one of these pulls up that record. Here’s an example of that:
When you click on an item on the left, the record appears on the right.
But what if your list is really long and you want to quickly get to a specific record?
In this example I’ll be showing you two techniques:
a) Create a portal that you can filter by typing into a field;
b) Enable navigation so that you can click on a record on the left to view it on the right.
1. Create a few global TEXT fields:
2. There is a custom function that makes the filter work; the easiest way to grab it is to import it from the demo database (link at the bottom); it’s called getStrings.
3. Create a CALCULATION field:
filterer = “all” & [carriage return] & getStrings ( company )
Important: Make sure that this is a STORED calculation; it needs to be indexed. The calculation result should be set to TEXT.
In this example I’m using the Company field for my filter.
4. Copy the scripts from the demo database. One of them is used for the filter, the 2nd is used for navigation.
5. On your search field (this is what you’ll use to filter the portal), set a script trigger to activate onObjectModify and trigger the script set portal switch.
6. In your relationship graph, create a self-join (two table occurrences based on the same table); the left side will be g_portal_switch and the right side will be filterer.
How It Works
When you type into g_searchstring, the script trigger activates; if there is text in the search field, your search text is put into the field called g_portal_switch. This field is what is used for the relationship that populates the portal.
So if you type “Amer” into the search field, that gets put into the portal_switch field, and the relationship finds all records that have that string (or more of it) in the filterer field.
The FILTERER field If you look at the filterer field (it’s on the tab labeled “Stuff that makes it work”), you’ll see that the custom function creates a list of text strings consisting of your company’s name in every permutation, from 1 character to the entire string.
If you empty the search field, the script trigger puts “all” into g_portal_switch; since “all” exists in the filterer field for every record, your portal shows you all of your records.
Lots of pieces to this, but it’s really fairly simple once you look at it…
The navigation that is used in this example is fairly straightforward. Make a button out of the portal field, and set it to perform the script go selected record.
How It Works
When you click on a portal row, the script sets the global g_selected to the ID of that record.
The 2nd step of the script uses Go to Related Record to show the selected record in the same layout.
Download a demo of this technique HERE