Blog

Often when working with FileMaker Pro, situations arise that call for completely custom scripting, in fact, if you use FileMaker custom scripting is something that will soon become second nature. The sample project in mind calls for using FileMaker to bridge between Billings 3 and iCal. The goal is to create a custom manner for pulling the timeslips from Billings 3 into iCal - Billings offers this but only as a day event, not hour by hour. At our consulting practice, we use a WebDAV timekeeping system to track the consultants hours, and have a specific way to pull all the hours into our system.

FileMaker has a couple of great script steps pertaining to AppleScript, alternatively FileMaker is also Scriptable via AppleScript. This gives it the ability to interact with AppleScript in two different ways. It can trigger AppleScripts and also be the object of AppleScripts calling it.

200812310033.jpg

For this project I'm going to focus on the "Perform AppleScript" function. The "Send Event" takes a little more explanation and has a wider scope than we need for this sample project.

For AppleScript we use Script Debugger, from Late Night Software, it's not free but if you want free the Script Editor in OS X is built in and its free.

Opening up the dictionary for FileMaker Pro Advanced (FileMaker Pro works fine and is scriptable also) shows us the complete AppleScript dictionary for FileMaker Pro Advanced.

200812310050.jpg

Through experience it seems the best way to work with AppleScripts that FileMaker is using to call other applications is to build the script in the Script Editor, run it and then make changes to it to work from within the FileMaker environment. FileMaker script steps that call AppleScript have only rudimentary functions for debugging and error trapping.

If the script is using variables or a calculated result, the script will change dynamically based on the record data and errors may occur. It's just quicker and a best practice to do the main script development in the outside environment and then bring that into the FileMaker script step.

Let's write the first script.

Launch Script Editor which can be found in the Applications folder in the AppleScript folder. There's several other items here that are useful. Make sure to check them out later.

200812310111.jpg

Copy the script exactly as it's show above, and the click compile the run (run will also compile on the fly). You should see iCal launch and come to the front.

All AppleScripts, unless they are saved as an applet need to be compiled before they can run. This is also the case with FileMaker Pro, it will compile the AppleScript before it executes it, when you use the Perform Applescript command in FileMaker ScriptMaker.

Take this text and cut and paste it into the dialog for the Perform Applescript step in ScriptMaker.

200812310118.jpg

Now run it, from the ScriptMaker menu or from a button, you should see FileMaker launch iCal.