2 Replies Latest reply on Jul 11, 2014 8:52 AM by JustinHesser

    Loop Go to Layout Error

    JustinHesser

      Title

      Loop Go to Layout Error

      Post

           The below script is used OnLayoutEnter of the "Location" page. When I use the script as written below, it never ends, but when I disable "Go to Layout ["Location" (location)]", it works perfectly fine, leaving me on the last "Person" record.

           My question is, why does this error occur and how do I fix it?

           If it makes any difference, I am using Filemaker Pro 13.

            

      Go to Layout ["Person" (Person)]

      Go to Record/Request/Page [First]

      Loop

      Go to Record/Request/Page [Next; Exit after last]

      End Loop

      Go to Layout ["Location" (location)]

        • 1. Re: Loop Go to Layout Error
          philmodjunk

               This script trips its own script trigger. Thus, it does all it was programmed to do, going to the last record, but then Go to Layout ["Location" (Location)] trips the OnLayoutEnter trigger and this script is performed all over again, trapping you in an infinite loop.

               This is one of the issues prompting a recent submission by me of a long list of changes I think should be made to improve this product: http://forums.filemaker.com/posts/56b3613440

               First, if all you want to do is make the current record on the "Person" layout the last record in its found set, use Go to Record/Request/Page [Last] and you no longer need the loop.

               Second, you can keep this script from getting trapped in an infinite loop if you modify it in this fashion:

               If [ Not $$TriggersOff ]
                  Set Variable [ $$TriggersOff ; value: True ]
             Go to Layout ["Person" (Person)]
             Go to Record/Request/Page [Last]
             Go to Layout ["Location" (location)]
                  Set Variable [$$TriggersOff ; value: False ]
               End If

               I almost always enclose all trigger performed scripts inside such an If block--all checking the value of the same global variable ($$TriggersOff) so that I can set this one variable to True whenever I want to disable all script triggers in my solution.

          • 2. Re: Loop Go to Layout Error
            JustinHesser

                 Thanks for the help Phil!