"Save Records as Snapshot Link" step causes confusing dialog if it's interrupted by a script trigger

Idea created by kupietz on Aug 29, 2018
    • jjsmith789

    [Reposted from Product Issues per @TSgal's instruction]


    It's a minor point, but I encountered a somewhat confusing error message. I have a logging script that runs from many different places a client's system. Today I added steps to it to save a snapshot link, load that into a variable, Base64 encode it, and pass it to a logging script running on the server via a script parameter, where it gets decoded and plugged into a container field in a new log record, so I have stored fmpsl of the current found set every time the logging script is called.


    Suddenly, my users started occasionally getting errors saying "Save Records As Snapshot Link has been canceled. Do you want to continue with the script?" even though the Save as Snapshot Link step didn't display a dialog, and hadn't been canceled.


    It turned out that, of the many places in the program that called the logging script, one of them was a popup menu that has "OnObjectExit" and "OnObjectSave" script triggers attached, and the "OnObjectExit" script called the logging script. What was happening then was, as soon as the logging script called the "Save Records as Snapshot Link" step, the "OnObjectExit" trigger fired again, calling the first script again, which, apparently, registered with FileMaker as if the user had canceled the Save as Snapshot Link step, which then presented an inexplicable (to the user) dialog. Strangely, once the second nested call of the first script called the logging script a second time, the "Save Records as Snapshot Link" step caused the "OnObjectSave" script to run, after which execution returned to the logging script and everything worked fine. I suppressed the error by turning on error capture and turning off user abort.


    I understand the behavior, and think it's mostly right, but maybe that dialog could be more descriptive of what's actually occurring. A script trigger probably shouldn't be considered "canceling" a Save Records as Snapshot Link script step and handled identically to a user canceling it, since that's not what's actually happening. It's a little opaque that "Save Records as Snapshot Link" re-exits an object that has already had its OnObjectExit triggered.