Auto Close a FileMaker Pro Database After a Set Interval Using an OnTimer Script Step


Databases can contain sensitive data. Sometimes you have a database you only open occasionally, but you don’t want to forget and leave the data file open on your computer. There are other solutions to this, including locking your computer screen after a set interval, but if you find that procedure overkill and just want to lock down one or two databases, FileMaker Pro (FM 10 or greater) has a solution for you: setup an Install OnTimer script that closes the database after a set interval minutes.

OnTimer-Workflow

The ‘On Open’ script contains an OnTimer Script with an interval of 5 minutes

wpid8784-media_1394583568550.png

The script it calls after the interval is the ‘Close Database after 5 minutes’ script.

Specify the interval in seconds

wpid8788-media_1394583898531.png

Enter the time before it executes in seconds (5 minutes x 60 seconds = 300)

More details on the Ontimer functions are available in FileMaker’s Help system.

Of note, the script step does not work in FileMaker Server, so this is designed for a local environment. On FileMaker Server there are other options, including a forced logout after a specified period of inactivity.

‘Close Database after 5 minutes’ Script

wpid8785-media_1394583595392.png

All this script does is close the database file.

File Options – On Open Script

wpid8786-media_1394583614895.png

To set up the script to run On Open, go into the File Options… under the File menu.

OnFirstWindowOpen run the On Open script

wpid8787-media_1394583630515.png

Select ‘Script Triggers’ panel and set the OnFirstWindowOpen script to ‘On Open’, which contains the timer to close itself after five minutes. Whenever the database is opened, a timer starts counting down. After five minutes, or whatever interval you have set, the database will close.

You could put more error checking into the script, test to see if a record is in use etc, but for my uses simple is best. Now you never have to remember to close that important FileMaker Pro file.

4 Responses to “Auto Close a FileMaker Pro Database After a Set Interval Using an OnTimer Script Step”

  1. I think this would be better if the timer was triggered once the FMP database was idle. Is that possible?

    • Not necessary for my needs, but there is a way to do this. The test would have to be in the Close Database script. If you just want to catch new or modified records something like this will work:

      Close Database Script
      #If the record is committed, then close the database immediately.
      If [ Get ( RecordOpenState )=0 ]
      Close File [ Current File ]
      Else
      #If not, try again in a minute to see if the record is closed.
      Install OnTimer Script [ “Close Database”; Interval: 60 ]
      End If

      This approach won’t catch records where you have clicked into a field, but not modified the field. Instead, use Get(ActiveFieldName) to see if the user is clicked into a field. If they are, call the script to run again in one minute, if not, then close the database:

      If [ IsEmpty(Get(ActiveFieldName)) ]
      Close File [ Current File ]
      Else
      Install OnTimer Script [ “Close Database OnTimer”; Interval: 60 ]
      End If

Trackbacks/Pingbacks

  1. Auto Close a FileMaker Pro Database After a Set Interval Using an OnTimer Script Step | Filemaker Info - March 12, 2014

    […] See on hbase.net […]

  2. Added Security - Auto Close a FileMaker Pro Database - FileMakerProGurus - March 13, 2014

    […] Auto Close a FileMaker Pro Database After a Set Interval Using an OnTimer Script Step | HomeBase Sof…. […]

%d bloggers like this: