Hi. I wanted to share this routine I programmed in order to close my Filemaker database files every workday around 6pm. This script only runs on my Win10 machine at work and then I have a separate script that runs on macOS at home to close the file there. The reason I needed this is during the pandemic I worked a lot more at home and sometimes I would accidentally leave the database open at one location and then open it at the other location. Then OneDrive, where the databases reside in the cloud, would create a different iteration of the file because it can't resolve the differences in FileMaker databases. Hard closing FileMaker via the Windows Task Scheduler was what I tried first but that ended up corrupting the database as it wasn't closed properly. So I created the below proper closing routine to avoid database errors. Timed or scheduled closing script.
This script is loaded upon file startup to set the Clock field which is a calculated value as "Hour ( Clock )" in 24-hour notation.
#Run script to update Clock field every 15 minutes and close file after specified hour
Set Field [ PD::Clock; Get ( CurrentTime ) ]
Install OnTimer Script [ “Clock Update”; Interval: 900 ]
Below is the above referenced "Clock Update" script that runs in 900 second intervals via the OnTimer Script.
Set Field [ PD::Clock; Get ( CurrentTime ) ]
# Auto Close file after hour 18 (6pm) on Intel to avoid cloud sync conflicts with home
If
[ PD::Clock > 18 ]
Perform Script [ “Close All Files via Listing Database” ]
End If