5 Replies Latest reply on Aug 1, 2014 8:46 AM by AmberDavis

    Set script triggers OFF

    AmberDavis

      Title

      Set script triggers OFF

      Post

           I'm Using Go To Related Records to pull up a found set of portal records on a layout. I then loop through the records on this layout instead of portal rows. THE PROBLEM: "This method can trip a very large number of script triggers on each of the two layouts involved. A global variable is necessary to keep such trigger performed scripts from doing anything while this script is changing to and from layouts. And the portal will "snap back" to the first portal row after you return to the original layout." -PHIL I am having troubles placing the triggers off variable. No matter where I place it, when the script runs it doesn't perform any finds, seems to just do nothing. My thoughts are I need to enclose Go to Layout with the variables so it doesn't perform the script. Thoughts?

      Set Variable [$$TriggersOff; Value:1]

      Set Variable [$$TriggersOn; Value;0]

      Screen_Shot_2014-07-31_at_2.56.11_PM.png

        • 1. Re: Set script triggers OFF
          AmberDavis

               The point of this script is it takes values from a portal located in ShopOrderForm (PurchaseOrders) layout. And shows related records on a layout called RelatedShopItems (Transactions). I then want it to get the names from the layout and mark it out of our inventory through the loop i created. And if there are multiple items then repeat and exit after last

          • 2. Re: Set script triggers OFF
            philmodjunk

                 Here's how to use a global variable to keep trigger performed scripts from interfering when you don't want them to:

                 Enclose each trigger performed script (This is the other script, not the one shown in your post) in an If block like this:

                 If [ Not $$TriggersOff ]
                    Put rest of trigger performed script here
                 End IF

                 Then, in the above script, you need to both turn triggers off and then turn them back on like this:

                 Set Variable [$$TriggersOff ; Value: True ] ---> you can use the number 1 here and get the same result
                 Put any steps that might trip a script trigger, such as your Go to Related Records step here

                 Set Variable [$$TriggersOfff ; Value: False ] ---> you can use zero if you prefer

                 As long as all trigger performed scripts are enclosed in the specified If block no trigger performed script will be able to interfere with your script between the time you set the variable to True and the time that you set it to False.

                 Design Notes: You may wonder why I don't set a variable named $$TriggersOn to False to disable trigger performed scripts. I could do that, but it would require me to initialize $$TriggersOn as True when the file is first opened. If [Not $$TriggersOff ] will evaluate as True if no value has yet been assigned to $$TriggersOff, so the method I use avoids that unecessary complication as variables will all start with no values when a file is first opened.

            • 3. Re: Set script triggers OFF
              AmberDavis

                   Phil, although it would seem easier to set the variable to TriggersOn and set it to false, your explanation does a very good job at explaining how it would be unnecessary evil. Also just an informative side note... instead of making my If statement like you suggested I made it so:

                   If [Not $$TriggersOff]

                      Exit Script [Result: 1]

                   End if

              • 4. Re: Set script triggers OFF
                philmodjunk

                     That also works, but I see no reason to specify a result for Exit Script.

                • 5. Re: Set script triggers OFF
                  AmberDavis

                       Eh, why not! wink