Quitting script issue, solved
If you upload FileMaker databases to a server via FileMaker client, you may have noticed an issue with onLastWindowExit scripts.
If the script does something elaborate that takes a few seconds, the server upload module can time-out. Occurrences in these final scripts might be saving system state settings (user prefs, etc), clearing temporary data, showing a shutdown ‘splash’ page, interacting with other, remote databases, etc.
To overcome this, add an IF statement to the onLastWindowExit script using
get(activemodifierkeys) = 1. If you are holding the shift key down on file close, the script performs the minimum required steps, and exits quickly.
(One of the essential steps it performs is to clear all globals (as these get baked-in once you upload to the server).)
FileMaker and SQL
Handily, there’s a little modular script to do this, which uses SQL to grab all global field names:
// select all fields from TOs with no spaces in their names (only PTOs)
// and FieldType is global
§SQL = "SELECT TableName, FieldName FROM FileMaker_Fields
AND NOT TableName LIKE '% %'
AND FieldType LIKE 'global %'
ORDER BY TableName,lower(FieldName) ASC
§List = ExecuteSQL( §SQL ; "::" ; "" );
§List = "?" ; "" ;
Once you have this list, it’s quick and easy to loop through the it using
SetFieldByName to clear each one.
Being globals, it doesn’t matter which layout you are on to do this, as global can be addressed from anywhere. In fact, it runs so quickly that you can run it as part of the default closedown procedure.
Best of all, because it’s polling Filemaker for the list of globals each time, the script never needs updating, and can be drooped into any solution (as long as the PTOs don’t have any spaces in their names).
That’s all for now. Please feel free to contact us or respond below.