Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

Dynamically filtered portal + multiple predicate relationship = I need help


This topic is 4181 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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?

 

 

Posted

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

Posted

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.

This topic is 4181 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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