Recurrence in triggered scripts

Recurrence can be really useful. But there are occasions when it is not exactly what you want. For example what happens when you have a script triggered on layout load that goes to another layout then returns? Recursive behaviour is unlikely to be required.

There are a few options to avoid looping ad infinitum. First, and most obvious, is to set a variable to flag the first time the script runs then exit or halt:

Set Variable [$$scriptTrigger; Value:$$scriptTrigger +1]
If [$$scriptTrigger > 1]
Set Variable [$$scriptTrigger; Value:””]
Exit Script [“We exited the script because it is running more than once”]
Else
Go to Layout [“Other Layout” (Table)]
# The script steps we actually want to trigger go here
Go to Layout [original layout]
End If

You can use the Halt Script step in place of Exit Script but it is better to exit with a meaningful value.

Darren Kayes

Darren is Linear Blue's Chief Operations Officer, ensuring the smooth running of the company and making sure nothing gets in the way of our developers creating top-notch web and database solutions for our clients.

More Posts - Website

Leave a Reply