Jump to content

Script Triggers and Unwanted Looping


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

Recommended Posts

Hi folks ... after 5 hours of solid head beating, googling, experimenting and no luck ... I turn here.

I have a script that works well when fired manually. But if I try to use it as a layout script trigger it loops. I understand why (I think) but I can't devise a work around.

Here's the background.

- I have two tables (Clubs and People)

- records in each table contain geocode information (latitude/longitude)

- I can run a script that determines the Person's location and can then calculate a secondary set of latitudes and longitudes that represents a 50 mile radius. (ie if latitude was 10.0 and I calculate latitude-variation and latitude+variation I will get a latitude search string of, for sake of argument, 8.5 ... 11.5 and then do the same with longitude)

- I can then plug this search string into the Clubs table and find the clubs that exist within that 50 mile radius. I give this foundset a global value (2)

- In my People page I have a portal that displays these results based on a relationship where the People page also has a global value of (2).

Here's the problem

- If I run this script manually, no problem. Works slick

- But I want to be able to advance record by record in the People section and have the portal populate with the Clubs in the vicinity of the Person.

- The rub seems to come when it flips from layout to layout (even though it's faster than the human eye) it repeatedly sets off the trigger. Hence the loop

- I've tried OnRecordLoad, OnRecordCommit, OnLayoutLoad and even OnModeEnter. Same results.

- I can't seem to be able to set the fields for the find request without switching to the Club layout and then I have to switch back to the People layout to see the results in the portal.

Any suggestions or work arounds? I appreciate you consideration.

Cheers

Link to comment
Share on other sites

I am not sure I understand your description, esp. the part where you "give this foundset a global value (2)". I think your problem could be solved by having the script open a new window, and close it when done - this way it never needs to come back to the original layout.

Another way to control script triggering is to set a global $$variable flag when the script is running - and exit the script if another script is already running.

Of course, the problem with your overall method is that it will only work in single-user mode.

See also:

http://fmforums.com/forum/topic/71942-limiting-number-of-portal-results/

Edited by comment
Link to comment
Share on other sites

Why can't you simply use a filtered portal from People to Clubs? I don't see the need for scripts, globals, etc.

I've tried to but not successfully.

In the simplest of terms: I have the following two simple tables

Table 1

ClubName

Latitude ( ie. 63.500)

Containing records:

Calgary - 51.543

Edmonton - 51.890

Saskatoon - 48.999

Toronto - 41.876

Table 2

PersonName

Latitude

Containing records:

Sam - 49.625

And assuming for a moment that I want to show (in the portal) all the Club records that are greater to Sam's location

I created the relationship ClubsName:Latitude < PersonName:Latitude

It should show in the portal 2 records (Calgary and Edmonton).

I'm sure I'm missing something obvious but ugghhhh I can't figure out what.

Link to comment
Share on other sites

I believe the thread that comment linked to will solve your problem (requires FM11 for the use of a filtered portal).

BTW, Calgary and Edmonton in your example have latitude's greater than Sam's and so, given your relationship, the cities Saskatoon and Toronto will show. Also, the relationship is stated backwards, that is Person is on the left and Club on the right.

Link to comment
Share on other sites

This topic is 4830 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.