AnsweredAssumed Answered

OnWindowOpen trigger doesn't run if a window is opened by Go To Related Record

Question asked by anothersmurf on Nov 13, 2018
Latest reply on Jan 11, 2019 by anothersmurf

Product and version (e.g. FileMaker Pro 14.0.3) FileMaker Pro 17.0.2.205

OS and version Mac High Sierra

Browser and version (for WebDirect only) -

Hardware Mac Pro

Description

Under File Options, a script is supposed to be triggered OnWindowOpen. But when a script uses the Go To Related Record script step, with "Open in new window" checked, the OnWindowOpen action is not triggered.

How to replicate

1. Your database needs two tables, related to each other by KEY. For a given record in TABLE1, at least one related record should exist in TABLE2. At least one layout should exist for each table.

2. Create a script called WinOpen, with a single step, Display Dialog "Hello".

3. Create a script called Relate, with a single step, Go To Related Record. Get records from TABLE2, using an appropriate layout. Check the "Show in new window" box. Check "Show only related records", and choose "Match all records in current found set".

4. Go to File-->File Options-->Script Triggers, check the box for OnWindowOpen and choose the WinOpen script.

5. From a layout based on TABLE1 with at least one record showing, run the Relate script (e.g. from the Scripts menu). A new window opens with related records, but the OnWindowOpen trigger script WinOpen did not run.

Workaround (if any)

If there are no other triggers in play, you can just call the WinOpen script explicitly after the Go To Related Record step in every script that uses that step to open a new window.

But if the target layout has an OnLayoutEnter trigger, the workaround may not be acceptable, because the the OnLayoutEnter trigger will run *before* the explicitly called WinOpen script, instead of *after* it, as would be the case if the OnWindowOpen trigger worked.

Outcomes