wrap the steps of the script that fires onLayoutEnter in an if statement that checks for a value in a global variable.
if ( $$FireTriggers = True ) then
<<insert script body here
all you have to do is set the global to anything but 1 to prevent the actions of the script.
The trigger will still fire and the script will run but it wont do anything.
As a practice i wrap all scripts that are fired by triggers with a similar construct
Use a global so you can change the value while debugging
Do I have to set the $$TriggerFire to True when I exit the layout? Is that normal behavior for the OnLayoutEnter to run, when I run the script from the record?
1 of 1 people found this helpful
I would turn the logic of this around.
At the start of your ONLayoutEnter trigger performed scirpt, write it this way:
If [ $$TriggersOff ]
Exit Script 
#Put original script steps here
Then, in your script that opens the new window, do it this way:
Set Variable [$$TriggersOff ; value: True ]
And at some point before this script exits, put in:
Set Variable [$$TriggersOff ; value : "" ]
This leaves your trigger enabled as your default state and you only need create/define that variable when you need to disable a script trigger. I start all my trigger performed scripts with these steps so I have the option to disable them from another script at need.
Thanks, that worked great. I am still curious, should the OnLayoutEnter trigger even be run when I click on a button that is on a record line?
It is normal behavior for New Window to trip both OnLayoutEnter and OnRecordLoad on your current layout. That's because you are entering a layout and loading a record in that new window. It just happens to be the same layout that you already have entered and loaded a record in the first window until you also change layouts in that new window.
One way around this that can sometimes be used it to use Go TO Related records to both open a new window and also specify a layout for that new window.
Okay thanks, just wanted to be sure it was normal behavior and I didn't mess something up.
One last question, what is the advantage of using a global variable over a global field, its seems I read somewhere that you shouldn't use too many global fields. It also seems like they start to clutter up the script debugger. Thanks
Much of the time either a global field or a variable may be used. There are differences:
A) a global field can be placed on a layout and directly edited by a user. A global variable cannot.
B) a global field can be used as a match field in a relationship. A global variable cannot.
C) A global variable does not exist in your relationship until it is created by set variable or the let function gives it a value. It persists until the file is closed or it is set to an empty string.
D) References to variables are faster than field references.
Thanks for the help, I appreciate it.