2 Replies Latest reply on Jul 31, 2013 12:40 PM by Matty_1

    Triggers when suing automated scripts.

    Matty_1

      Title

      Triggers when suing automated scripts.

      Post

           What I'm looking to do is setup some sort of variable that tells a script whether it should deploy or not while in the middle of another script that say assigns records to invoices or creates new records.

           I've never had to use this type of thing in the past and now that last two processes I've tried to create have cause issues in a bunch of scripts because they involve activating when switching to and from certain modes etc.

           I've seen this method gets used in the past but I don't have any databases to refer to so I'm wondering if someone could give me pointers on this.  Is it as simple as turning a global variable from on to off.  When a script that I want to run uninterrupted starts it marks the variable as off, performs it's script and then turns it on at the end.  All scripts that I want to have affected by this would always start by checking if the script switch is on or off ... seems like that would do the trick but wanted to see what others thought.

            

           Thanks!

        • 1. Re: Triggers when suing automated scripts.
          philmodjunk

               I think you have encountered a common problem with script triggers. A given script can easily trip script triggers that then perform other scripts which interfere with the first script. A classic example is when a script changes layouts and then OnLayout Enter, OnLayoutExit, OnRecordLoad, OnObjectEnter, OnObjectExit all might be tripped by the layout change.

               I have developed the habit of enclosing my trigger controlled scripts in the following If block:

               If [Not $$TriggersOff ]

                  # put the rest of the script here

               End If

               Then if I have a script that needs to keep from tripping triggers, I use this code:

               Set Variable [$$TriggersOff ; value: True ]

               Put steps that might trip a script trigger here

               Set Variable [$$TriggersOf ; Value: False ]

               In other cases, I can avoid tripping triggers by using Go to Layout to go to a "utility layout" based on the table I need, but which has no script triggers defined and which is hidden from the layout drop down in the status tool bar so that users can't access it.

          • 2. Re: Triggers when suing automated scripts.
            Matty_1

                 Perfect, thank you Phil!