Triggering FileMaker Scripts from OmniGraffle

One of the most powerful and exciting aspects of creating and implementing multi-platform FileMaker solutions, is their ability to respond to requests from other applications to execute the FileMaker script components of the targeted databases. This is accomplished by activating and using the built-in fmurlscript support in FileMaker.

To enable fmurlscript support in a database, open the file in Filemaker Pro on macOS (or Windows), and select the menu option for: File > Manage > Security… and in the forthcoming dialog, assign the privilege sets that are allowed to use this function.

The example database and scripts provided with this documentation, require full access privileges to run scrpts locally on the device.

fmurlscript

Once enabled, you can construct URLs using the fmp:// protocol to instruct the FileMaker solution to execute one of its FileMaker scripts. You can even provide values for variables used in the FileMaker scripts!

The fmp:// protocol supports a wide range of options and parameters. You can specify network IP addresses, and even open specific FileMaker database files located the user’s Documents folder.

For the purposes of the example database included with this documentation, it is designed to reside and be hosted on the same device that has the open OmniGraffle document.

When using and targeting a local database, the fmp:// protocol provides a shortcut form for specifying the local database:

 1  A URL for executing a FileMaker script. The dollar sign ($) indicates that the currently open database file is the target of the URL. It is followed by a forward slash and the URL encoded name of the database. The question mark (?) character delineates the parameters portion of the URL and is followed by the parameter name “script” an equals sign (=) and the URL encoded name of the script to be executed.

 3  A URL for executing a FileMaker script with a specified value for a script variable. Follows the same construct as the previous URL with the addition of an ampersand character (&) followed by the name of the FileMaker script variable ($variableName) an equals sign (=) and the URL encoded value for the FileMaker variable.

Omni Automation scripts can dynamically construct fmurlscript URLs while passing information, such as the value of a graphic’s metadata tags, to the FileMaker script to be executed.

Show Related Record

The Org-Chart Connector PlugIn contains an action that displays the source record of the metadata assigned to the currently selected graphic. This script uses the fmurlscript protocol to trigger FileMaker to search all records and display the one whose field Employee ID contains the value passed in the URL.

/*{ "type": "action", "targets": ["omnigraffle"], "author": "Nyhthawk Productions", "description": "Displays the FileMaker record related to the selected graphic.", "label": "Show Record for Person", "shortLabel": "Show FM Record" }*/ var _ = function(){ var action = new PlugIn.Action(function(selection,sender){ // action code cnvs = selection.canvas graphic = selection.solids[0] DBFILENAME = graphic.userData['Database Name'] DBFILENAME = encodeURIComponent(DBFILENAME) DBIDFIELDVALUE = graphic.userData['Employee ID'] FMSCRIPTNAME = 'Find by ID' FMSCRIPTNAME = encodeURIComponent(FMSCRIPTNAME) urlStr = "fmp://$/" + DBFILENAME + "?script=" + FMSCRIPTNAME + "&$TARGETID=" + DBIDFIELDVALUE url = URL.fromString(urlStr) url.call(function(reply){}) }); action.validate = function(selection,sender){ // validation code if(selection.solids.length === 1){return true} else {return false} }; return action; }(); _;

 16-17  Extract and URL encode the name of the source database from the metadata assigned to the selected graphic.

 18  Extract the Employee ID from the metadata assigned to the selected graphic.

 19-20  Instantiate a variable containing the URL encoded name of the FileMaker script that will locate and display the related record.

 21  Instantiate a variable containing the FileMaker URL created used the data retrieved from the assigned metadata tags of the selected graphic.

 22  Create a URL instance using the fromString() method of the URL class. Note that the FIleMaker URL includes both the name and value of the FileMaker variable $TARGETID whose value is the Employee ID of the person whose metadata is assigned to the selected graphic.

 23  Execute the call() method of the URL class on the created URL instance.

The FileMaker Script

The FileMaker script URL is received by FileMaker and is translated into the set of instructions contained in the URL. In this case, the action is to run the FileMaker database script “Find by ID” setting the value of the variable $TARGETID to the value passed in the URL. Once executed the related record will be displayed.

script-edit-window

 1  The FileMaker searching script selected in the Script Workspace window.

 2  For this script there is only one script action: performing a Find quest.

 3  The edit window for a Find request.

 4  Search the database for the record whose field Employee ID contains the value in the FileMaker variable: $TARGETID

UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER