1 Reply Latest reply on Oct 15, 2016 7:54 PM by user17152

    Better MouseTrap: Copying Records without Triggering Layout Enter?


      I am using a script that is trigged when you "enter" the layout.


      The script determines if there are any records for a given project and if no records exist for that project, the user is then asked if they would like to import the records (about 150 records) for the project they are working on.


      If they user selects to import the records to the project, the script will Freeze the Windows, switch to another layout and grab the first of the 150 records that need to be imported.  A loop is entered, variables set, and then the script switches back to the "original" layout in order to add the imported record to the project table.  This where the problem lies -when the layout switches back it triggers another "layout enter" event and the script starts all over again.


      Is there a way I can do this without triggering the repeated instances of layout enter?  The current workflow is highly desired in that a user can open the layout and import the records all in one step - which minimizes issues and simplifies interaction.


      I have attached screen shot of my current script. Line 17 is where the script attempts to reset the context and where the new "on enter" trigger is unfortunately fired.


      Truly appreciate any guidance as I am new to scripting and have tried various approaches but they all seem to lead to a wall.


      Thanks in advance!

        • 1. Re: Better MouseTrap: Copying Records without Triggering Layout Enter?

          I've encountered something similar.  Use a global variable to temporarily disable the script from running when you switch layouts.  The variable needs to be global so that the next time the script runs, that instance of the script can see the variable.


          At the very beginning of your script, use an IF statement to exit the script if $$skip = 1.


          Inside your IF Get ( LastMessageChoice ), set the variable $$skip to 1.  And the end of this IF statement, once all of the actions are complete, set $$skip = "", thus destroying it.


          The first time the script runs, $$skip does not exist, so the script will proceed as normal.  Once the user says "yes" to importing, $$skip is set to 1.  As soon as the layout enter script trigger runs, it will exit because $$skip = 1.  Before your script ends, clearing $$skip makes sure there's no $$skip variable when the user moves on to the next record.


          There might be other ways to do this, but this is how I've handled something similar.

          1 of 1 people found this helpful