1 Reply Latest reply on Dec 30, 2013 8:35 AM by philmodjunk

    Looping off on trigger or tricking script

    ChrisJohnston

      Title

      Looping off on trigger or tricking script

      Post

      Per this document here I have been able to better understand why there are considerations for using a loop in a script that runs when the page loads. Does anybody have examples of this done properly to not cause the repeating loop problem? I have started testing what I figured is a way to sort of trick it in to not knowing its recursive self. What I am working on is a way to make the script let another layout do the work with the loop and then come back to the layout telling it not to run any scripts. The not to run any scripts part is what I am trying to figure out. Also I don't understand what is being referred to as the object. I know what an object is but I can’t see it here. I don't know if someone can easily see what the object in my script is but I put a sample of it anyway. Thanks


      Set Field [INFORMATION::record_listing; ""]
      Set Variable [$infid; Value:INFORMATION::_kp_information_id]
      Set Variable [$infname; Value:INFORMATION::information_name]
      Go to Related Record [Show only related records; From table: “INFORMATION_Topic”; Using layout: ]
      Set Variable [$reclist; Value:If (  Get(FoundCount) = 0;  $infid;  $infid & "¶" & GetFoundSet("_kp_information_id")  )]
      Set Variable [$reclistnm; Value:If (  Get(FoundCount) = 0;  $infname;  $infname & "¶" & GetFoundSet("information_name")  )]
      Loop
        Go to Related Record [Show only related records; Match found set; From table: “INFORMATION_Topic”; Using layout: ]
        Exit Loop If [Get(FoundCount) = 0]
        Set Variable [$reclist; Value:$reclist & GetFoundSet("_kp_information_id")]
        Set Variable [$reclistnm; Value:$reclistnm & GetFoundSet("information_name")]
      End Loop
      Enter Find Mode []
      Set Field [INFORMATION::_kp_information_id; $infid]
      Perform Find []
      Show All Records
      Set Field [INFORMATION::record_listing; $reclist]
      Set Field [INFORMATION::record_listing_name; $reclistnm]
      

        • 1. Re: Looping off on trigger or tricking script
          philmodjunk

               A script that changes layouts could trip any number of script triggers including OnLayoutEnter.

               I use the following method to keep a script from tripping triggers:

               Set Variable [ $$TriggersOff ; True ]
               #Put the rest of the script here
               Set Variable [$$TriggersOff ; False ]

               If you have points in your script where a Halt or Exit terminates the script, you'll need to add that second set variable step just before the Halt or Exit script.

               Then, in every trigger controlled script that might be tripped by such a script, I put the entire script inside an IF block like this:

               If [ Not $$TriggersOff ]
                  #Rest of script goes here
               End IF

               This will keep your trigger controlled scripts from being performed when a script trips their triggers.