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.

Dynamically filtered portal + multiple predicate relationship = I need help

Featured Replies

Here's a curly one for the FM gurus out there. I'm not bad at FM but It's only a hobby for me at this stage.

 

The situation:

1. I have a db of postcodes in a single table. Each postcode location has geo-location latitude and longitude fields that are retrieved via a script from Google's API. (This only happens on data entry.)

2. I have a dynamically filtered portal called related postal codes. The standard trick here. Set up a relationship using a related_by global field with radio button selections that generate a result in a related_key 'Case' statement to filter the portal by relating  with a related_multikey calculation field that contains a list of the selections separated by carriage returns. Its all there even in FM's starter files.

3. I have a custom function GeoBoxBounds from Brian Dunning (I have renamed it GeoBox) that effectively returns a find result based on latitude and longitude to produce all the postal codes at a specified radius/boundary from the active record's location. (It does precisely what I envisaged.)

4. I thought that this would be a good one to add to the dynamically filtered portal but ah ha not so easy.

My selections are "Name", "Town, City", "Region", "Within 1 Km", "5 km", "10km"

 

The problem is that If you want to do the GeoBoxBounds via a relationship then you need a 'multiple predicate relationship' to be able to return the range of latitudes and longitudes activated by the selections for the custom function to work. i.e. a relationship with latitude 1...latitude 2 denoted as <= and >= . Doing this would mean the straight forward selections such as "Region" required for the dynamically filtered portal will no longer work.

 

I have proof of concept using a script trigger to find the range of records first and flag them with 'replace field contents' in a flag field so that the dynamically filtered relationship can work with each found set too. Of course this is very clunky because I need to clear the flag fields contents each time I wish to select something new and with 16000+ records...

 

I'm just wondering if I'm missing something that would make things so much easier.

 

This is the the triggered script to date to give you an idea.

 

 

If [ PatternCount ( Postal_Codes::Related_By ; "km" ) ] Show All Records

Replace Field Contents [ Postal_Codes::Found_Within; Replace with calculation: "" ] [ No dialog ]

Set Variable [ $RecordID; Value:Get ( RecordID ) ] If [ Postal_Codes::Related_By = "Within 1 Km" ]

Set Variable [ $GeoBox; Value:GeoBox ( Postal_Codes::Latitude ; Postal_Codes::Longitude ; 1000) ] Else If [ Postal_Codes::Related_By = "5 Km" ]

Set Variable [ $GeoBox; Value:GeoBox ( Postal_Codes::Latitude ; Postal_Codes::Longitude ; 5000) ] Else If [ Postal_Codes::Related_By = "10 Km" ]

Set Variable [ $GeoBox; Value:GeoBox ( Postal_Codes::Latitude ; Postal_Codes::Longitude ; 10000) ] End If

Enter Find Mode [ ] Set Field [ Postal_Codes::Latitude; GetValue ( $GeoBox ; 1 ) & "..." & GetValue ( $geoBox ; 2 ) ]

Set Field [ Postal_Codes::Longitude; GetValue ( $GeoBox ; 3 ) & "..." & GetValue ( $geoBox ; 4 ) ]

Perform Find [ ] Replace Field Contents [ Postal_Codes::Found_Within; Replace with calculation: $RecordID ]

[ No dialog ]

Else End If

 

Any thought's people?

 

 

Don't change the values of the records you want to find, but adjust the search parameters. See if this sample file helps you; for instructional purposes, it uses both a filtered relationship and a filtered portal.

 

EDIT: Here's a version that uses only a filtered portal and $$s.

AdjustSearchParameters_portalFilter_eos.fp7.zip

  • Author

Thank you very much eos. I knew there was a better way so this is exactly what I needed to help clarify the logic.

 

I did get my version working reasonably well by first adding a " * " find request on the flag field to minimise the replace step but i still knew I was barking up the wrong tree as my script grew.

 


I will go through your example and see how I can incorporate the logic to geo co-ordinates + other search criteria. 

 

I will post back and let you know.

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.