Undocumented OnTimer Trigger Behaviour

We discovered an undocumented behaviour with the OnTimer script trigger.

One of our solution scripts executes the Install OnTimer Script script step on a document window. At a later time, a user action causes the creation of a card window.

Testing revealed a bug. We forgot that new windows inherit the original window's OnTimer Script. It did weird things when it fired in the context of the card window. We fixed this error, but found an unexpected behaviour in the process of debugging.

The Install OnTimer Script topic of the Claris FileMaker Pro 19 Help points to another topic, About window styles. The latter mentions OnTimer scripts only once, in the Dialog window section. It states:

… OnTimer scripts do not execute when a dialog window is open unless the script launches from the dialog window itself.

We took this to mean that script triggers fire for parent windows of card windows because the Card section makes no mention of OnTimer scripts.

Not quite! The OnTimer script fires only when the card window is closed (and, of course, all scripts are done running). It forced us to rethink our use of the OnTimer script big time.

Here's hoping this observation saves you some time.

4 Likes

Well explained, Claris oughta update their documentation to reflect the behavior with card windows.

Interestingly, we can take advantage of this behavior for some things. For example, in a script you can set an ontimer callback on the parent window, then open up a card window for user input. When the user finishes and closes the card, the OnTimer can retrieve the results. This is good for data entry and pickers. Here's a basic example I made a while back: OnTimer Card.fmp12

I think Logicator from beezwax uses this technique, and I'm sure Geist Interactive does for some of their stuff too.

As you alluded to already, if you open up a card window from the current file, it inherits the parent window Ontimer so you have to clear the OnTimer on the card after opening. That's not the case if you open a card from another file like Logicator, though.

4 Likes