Home > FileMaker > Recurrence in triggered scripts

Recurrence in triggered scripts

April 16th, 2009

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.

Damian Kelly FileMaker ,

  1. No comments yet.
  1. No trackbacks yet.

Comment Spam Protection by WP-SpamFree