Init script won't set variables the first time a file is opened

Discussion created by johnnyb on Nov 20, 2015
Latest reply on Apr 5, 2016 by TSPigeon

In a script that runs OnFirstWindowOpen, I run a query against an Users table and set a ten global variables from the result.

The first time this script runs after opening FileMaker Pro, some of the variables don't get set. It's the same variables each time, but the exact variables affected change if I change the order of the script steps, while the order of the script steps doesn't seem to reflect which do or don't get set. Nothing special about the fields… all are plain text but one from a related table.

If I close and re-open the file without quitting FileMaker Pro, all the variables get set.

If I have the debugger open and step through the script, even on first launch, all the variables get set. There are no errors.

I thought the script might be running too fast somehow… but if I insert a "Pause/Resume Script" for 3 seconds after the query and before setting the variables, it doesn't help.

Anyone seen anything like this? Any ideas?