Filemaker Pro AppleScript - Part 1

If you are a Filemaker Pro developer working on Macs will know that this versatile database has had AppleScript support built in for many years. It’s a versatile and simple way to extend the functionality of Filemaker Pro allowing you to perform complex scripting tasks within the application or even link Filemaker Pro to other applications.

If you’re coming to Filemaker Pro Applescript for the first time, these script samples will hopefully help you get started.

—–

Let’s assume we’ve built a Filemaker database called “mcContacts” with a table called “Contacts” and four fields: “First Name”, “Last Name”, “email” and “Postal Code”

You can download the sample database here

How to create a new record:

tell application "FileMaker Pro"

 create new record in database "mcContacts"

end tell

How to create a new record and insert content:

tell application "FileMaker Pro"

 set newRecord to create new record in database "mcContacts"

 tell newRecord

 	set cell "First Name" to "Henry"

 	set cell "Last Name" to "Higgins"

 	set cell "Postal Code" to "HH1 3HH"

 	set cell "email" to "hhiggins@email.com"

 end tell

end tell

How to modify the current record:

set newFirstName to "Horace"

set newLastName to "Walpole"

tell application "FileMaker Pro"

 set cell "First Name" of current record to newFirstName

 set cell "Last Name" of current record to newLastName

end tell

How to get and display information from a record:

tell application "FileMaker Pro"

 tell database "mcContacts"

 	set firstName to the contents of field "First Name" of current record

 	display dialog "First Name in this record is: " & firstName

 end tell

end tell

How to delete the current record:

tell application "FileMaker Pro"

 tell database "mcContacts"

 	delete current record --be careful, there's no warning

 end tell

end tell

How to search for a record:



tell application "FileMaker Pro"

 tell database "mcContacts"

 	show (every record whose cell "First Name" = "Henry")

 end tell

end tell

How to search for a record with multiple search terms:



tell application "FileMaker Pro"

 tell database "mcContacts"

 	show (every record whose cell "First Name" = "Henry" and cell "Last Name" = "Higgins")

 end tell

end tell

How to show all records:

tell application "FileMaker Pro"

 tell database "mcContacts"

 	show every record

 end tell

end tell

How to sort the current records:

tell application "FileMaker Pro"

 tell database "mcContacts"

 	sort layout "Contacts" by field "Last Name" in order ascending

 end tell

end tell

How to show a particular record:

tell application "FileMaker Pro"

 tell database "mcContacts"

 	show record 2

 end tell

end tell

Also useful - perform a menu command:

tell application "FileMaker Pro"

 do menu menu item "Hide Window" of menu "Window"

end tell

Also useful - perform a script:

tell application "FileMaker Pro"

 tell database "mcContacts"

 	do script "Test"

 end tell

end tell

Finally, how to get Filemaker to make the tea:

tell application "FileMaker Pro"

 tell Metaclarity CEO "Paul Tuckey"

 	go an make the tea with delay 0

 end tell

end tell

We hope this helps you get up and running with AppleScript and Filemaker Pro. Stay tuned - we’ll be publishing Part 2 very soon!

One Response to “Filemaker Pro AppleScript - Part 1”

  1. ynetoydj Says:

    ynetoydj…

    ynetoydj…

Leave a Reply

You must be logged in to post a comment.