Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 1242 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted (edited)

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

 

Edited by zonetuke
clarification
Posted (edited)

I don't see why you need the Clock field (and even less why you need it to convert the time to an hour). Couldn't you do simply:

If [ Get ( CurrentTime ) > Time ( 18 ; 0 ; 0 ) ]
  Perform Script [ “Close All Files via Listing Database” ] 
End If


Of course, you could avoid the constant checking by making sure that the closing script runs at 6 PM:

Install OnTimer Script [ “Close All Files via Listing Database”; Interval: Time ( 18 ; 0 ; 0 ) - Get ( CurrentTime ) ]

Personally, I would prefer to use the OS scheduler to open a "dummy" file that calls the closing script in the "real" file, then closes itself.


I hope someone more knowledgeable can comment on the wisdom of keeping a working file on OneDrive. I don't know how that works and I would be very worried about potential corruption - even if being sure that the file doesn't get opened by more than one user at a time.

 

Edited by comment
  • Newbies
Posted

Thank you for your suggestions as they appear to be more efficient. 

This topic is 1242 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.