Scheduling Scripts with FileMaker Server
Automation with FileMaker Server Scheduler
For many years automating tasks in a database hosted by FileMaker Server required a “robot” computer that used its operating system’s scheduler to open a dummy FileMaker database file at a particular time. The dummy database would then connect to a hosted database, trigger a FileMaker script, and then close FileMaker Pro. Robot machines worked for the most part, but there were many factors that could go wrong and often did. For example, the robot machine had to be on and running properly with an active network connection to the server.
FileMaker Server 9 introduced a feature that allowed FileMaker scripts to be scheduled in the FileMaker Server Admin Console. Scripts could run automatically without having a copy of FileMaker Pro running on the server or on a robot computer. This was a major step toward reliable automation and the end of robot computers.
Unfortunately, because the database wasn’t open in FileMaker Pro, not all script steps could be run on the server. FileMaker Server 10 has taken the script scheduling feature further by allowing server compatibility for many more script steps. Most importantly, FileMaker Server 10 allows for importing and exporting of data on the server. In this article, all examples of automation are based on an environment running FileMaker Pro 10 and FileMaker Server 10.

What would I want to automate?
Over the years IT Solutions has set up automation on many FileMaker systems, and for many different reasons. Most commonly, automation is used to create a set of records in bulk at a particular point in time so that they will be waiting when a user logs in and needs to use them. An example of this kind of automation is timesheet records for employees. On a particular day and time, such as Sunday evening or early Monday morning, timesheet records are created for all active employees. Another example is the creation of attendance records for a school. When a teacher logs in to take attendance, records for the day are already created for the teacher’s current class roster. All he or she has to do is mark the records for absent students.
Another kind of automation we are often asked to create has to do with updating statuses. System dashboards and classroom assignments are examples of statuses within a system that need updated. System dashboards often collect data elements from different sources within the database and then display them in one consolidated graphical overview. Updating dashboards a few times a day is often enough to provide a bird’s eye view of the organization.
In a school setting, students may be assigned to certain classrooms or programs for a particular amount of time. By allowing teachers to enter both start and end dates for those assignments, the system can update a student’s status automatically. Each day a server-scheduled script can run on all classroom assignments and set them to active or inactive based on the dates entered in the system. Additionally, the scripts can add or remove them from the student’s schedule, which may be stored in a separate part of the system.
A third type of automation deals with system integration. Certain types of SQL databases can have a real time connection with FileMaker using the ESS (external SQL source) feature. For systems that are not ESS compatible, integration scripts can be scheduled to run as often as required by an organization’s business rules. For example, when doing integration with an accounting package, such as QuickBooks, it is often required to batch post customer and invoice records at the end, or throughout, each business day. Likewise, balances may need to be pulled from the accounting package back into a FileMaker. These processes can be scheduled to occur as often as needed to allow for accurate representation of data in both systems.
Another example of automation for system integration is importing and exporting data to and from databases to maintain a single authoritative data source for an organization’s collective system. For example, FileMaker cannot establish a real time connection with SAP systems, but FileMaker Server 10 introduced the ability import data from an external file using a scheduled script, so long as it is located in a particular directory on the host server. So, we can schedule the operating system to copy a file into a particular location, and then schedule FileMaker Server to import and update data from that file in a hosted database. This keeps SAP as the authoritative source for certain data, but allows FileMaker users access to use that data at will. All of this can happen in the middle of the night or at particular time intervals without the need for user interaction.
Limitations
How can you tell whether or not a script step will work properly if it is included in a script that is scheduled to run on the server? The Manage Scripts tool in FileMaker Pro 10 offers a convenient compatibility checker located in the bottom left corner of the Edit Script window when modifying or building a script. By default the compatibility checker is set to “Client” which includes all script steps. Changing that value to “Server” or “Web Publishing” shows which script steps are not compatible to each respective environment by changing the color of the script step from black to gray.
Why are some script steps not compatible when running on FileMaker Server? When a script is running on FileMaker Server, no instance of the database will be opened in FileMaker Pro. This prevents certain kinds of actions from being possible. For example, layout dependent script steps, such as adjusting windows, showing a custom dialog box, or entering preview mode, will not be compatible because there is not layout available to the script.
Developers should use caution to only schedule scripts with 100% compatible steps. If the FileMaker Server attempts to run a scheduled script and it encounters an incompatible script step, the script will be aborted and an error will be written to the server log.
If you have any questions about automating your FileMaker solution using FileMaker Server script automation, please do not hesitate to contact me, Jason Mundok, at jason.mundok@itsolutions-inc.com or 866.PICK.ITS.