7 Replies Latest reply on May 18, 2017 1:27 PM by rcbmi1

    OnLayoutEnter Script Step Looping Issue

    rcbmi1

      Hi all,

       

      I am attempting to set up a notification system so that the admin of our database file can see which layouts users are accessing throughout the day, as well as the time spent on a given layout. The issue I'm running in to is this:

       

      I have created a script which set variables for the time, the user performing the action, and several other pieces of information.

      This information is then copied using the Set Field Script Step to another table (System Table).

      If I use the Set Field Step, no new record is generated, so it simply copies over the last entry.

      If I use the Go To Layout Script Step, I get stuck in a layout change loop when I return to the original layout.

       

      Any thoughts on how to accomplish this?

       

      Running FMS15 with FM14 clients, mixed OS environment.

       

      Thanks,

       

      James

        • 1. Re: OnLayoutEnter Script Step Looping Issue
          planteg

          Hi,

           

          I suggest that you post your script.

           

          To create a new record in the System table, you need to use New Record/Request before setting the fields. Since the last entry is modified, this could be related to the Relationships diagram. I suggest you post also the Relation defining the context for your script.

          • 3. Re: OnLayoutEnter Script Step Looping Issue
            planteg

            Fine, you have New Record/Request ... but you don't need Go To Record/Request/Page [Last] because you make the last record current, explaining you overwrite it. Add a Commit Records/Requests before the Go To Layout and you're fine.

            • 4. Re: OnLayoutEnter Script Step Looping Issue
              philmodjunk

              There are two ways to fix the looping that you describe.

               

              One is to use a global variable field to disable the trigger performed script temporarily. The other is to use a method known as "magicKey" to create your records and add data without changing layouts. You can web search on MagicKey to find a number of very good articles on the method.

               

              To use a global variable to disable trigger controlled scripts, you can do the following:

               

              At the beginning of a script performed by a script trigger:

              If [ $$TriggersOff ]

                 Exit Script

              End If

               

              In any script that might trip the trigger for the above script do this:

               

              Set Variable [ $$TriggersOff ; Value: True ]

               

              Put it before the Go to layout or other script step that trips the trigger for the script where you've put the If step shown above. Then put:

               

              Set Variable [$$TriggersOff ; Value: "" ]

               

              Later on in the script, making sure that it comes before any exit script, halt script and the end of the script so that you don't leave the triggered script(s) disabled. Also be careful during testing scripts in the debugger, not to leave this variable set to True or you may find these scripts disabled when you don't want to if you use the debugger to halt the script before the second set variable step destroys the variable.

              • 5. Re: OnLayoutEnter Script Step Looping Issue
                rcbmi1

                Thanks for your suggestions.Which instance of Go To Layout are you referring to? And that doesn't solve the issue of the script repeating once the script sends the user back to the original layout.

                • 6. Re: OnLayoutEnter Script Step Looping Issue
                  planteg

                  Sorry,

                   

                  I was talking about the last one.

                   

                  Regarding the loop, it's caused by the fact that it's triggered by OnLayoutEnter. When you back to the original Layout, the OnLayoutEnter fires again and you get an endless loop. See philmodjunk comment to prevent that.

                  • 7. Re: OnLayoutEnter Script Step Looping Issue
                    rcbmi1

                    Thanks for the help. I will look into magicKey, but for the time being the Trigger variable is working.

                     

                    Regards,


                    James