AnsweredAssumed Answered

Script Triggers and unwanted looping

Question asked by SeanLibin on Jan 26, 2011
Latest reply on Jan 27, 2011 by philmodjunk


Script Triggers and unwanted looping


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/longtitude)

- 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 search string of for sake of arguement 8.5 ... 11.5)

- 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 displayes 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.