Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Script to auto-close file every day around 6pm

Featured Replies

  • Newbies

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

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

  • Author
  • Newbies

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

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.