Product Logo


Trigger and schedule scripts

Getting Started


This example shows some basics of creating events using the different plug-in functions. This example does not include an actual example database, so feel free to reproduce the calculations in your own database as you read through the explanation.

These functions would be placed inside a Set Field or Set Variable script/button step. For example:

Set Field[ db::results ; MMScript_CreateImmediateScriptEvent( “MyScript” ) ] or

Set Variable[ $results ; MMScript_CreateImmediateScriptEvent( “MyScript” ) ]

Error checking is especially important when using the Set Variable script step. If a function returns an error and you do not display or write the Variable data to a field, the error will never be seen and you will have no idea why the function did not work.

Trigger A Script Immediately

To run a script immediately, use the MMScript_CreateImmediateScriptEvent function. The format of the function is as follows:

MMScript_CreateImmediateScriptEvent( Script {; DB {; EventName {; EventValue {; Priority {; CurrentScript }}}}} )

The quickest way to run a script using this function is:

MMScript_CreateImmediateScriptEvent( “MyScript” )

The above code runs a script named “MyScript” in the current database.

If you need to trigger a script in a different database, you could use the following example:

MMScript_CreateImmediateScriptEvent( “MyScript” ; “AnotherDatabase” )

You can pass script parameters to your scripts by using the “EventValue” parameter:

MMScript_CreateImmediateScriptEvent( “MyScript” ; Get ( FileName ) ; “EventName” ; “EventValue” )

In the above example, “EventValue” can be any text or data that you can use with a normal script parameter. The “EventName” needs to be any event name not already in use.

Also in the example above, note the use of the “Get ( FileName )” function which is built into FileMaker. Using this function, rather than hard coding your database name in, can save a lot of time and frustration if you ever decide to change the name of your database file. This also makes the calculation more portable meaning you could copy and paste it into another database with minimal modification.

Schedule a Script

To schedule a script, use the MMScript_CreateDateTimeScriptEvent function. The format of the function is as follows:

MMScript_CreateDateTimeScriptEvent( EventName ; Script ; DateTime {; DB {; EventValue {; Persistent {; Priority {; CurrentScript }}}}} )

The quickest way to schedule a script using this function is:

MMScript_CreateDateTimeScriptEvent( “MyEvent” ; “MyScript” ; “8/15/2006 1:00:00 PM” )

The above code would run the script “MyScript” at 1pm on August 15, 2006. In this example, the Event Name is “MyEvent”. You can use this information in other functions such as, MMScript_UpdateScriptEventValue or MMScript_CancelScriptEvent to update this event.

Create an Idle Script Event

To create an idle script event, use the MMScript_CreateIdleScriptEvent function. The format of the function is as follows:

MMScript_CreateIdleScriptEvent( EventName ; Script ; IdleTime {; DB {; EventValue {; Repeat {; Persistent }}}} )

The quickest way to schedule a script using this function is:

MMScript_CreateIdleScriptEvent( “MyIdleEvent” ; “Time Out” ; “15m” )

The above code will run the script “Time Out” if the user does not interact with FileMaker for 15 minutes.

If you want the event to activate again once the user does interact, then you want to set the “Repeat” parameter to True….

MMScript_CreateIdleScriptEvent( “MyIdleEvent” ; “Time Out” ; “15m” ; Get ( FileName ) ; “MyValue” ; True )

Create an Interval Script Event

To create an inverval script event, use the MMScript_CreateIntervalScriptEvent function. The format of the function is as follows:

Interval {;
DB {;
EventValue {;
StartDateTime {;
Repeat {;
Persistent {;
Priority {;
}}}}}}} )

The quickest way to schedule a script using this function is:

MMScript_CreateIntervalScriptEvent( “MyEvent” ; “MyScript” ; “1h 30m” )

The above code will run the script “MyScript” in one hour and thirty minutes.

This function is quite flexible. You can use it to repeat a script at any interval and you can have it start on a certain day. For example, you could use this plug-in to remind you that New Year’s Eve is on its way:

“New Years” ; // Event Name
“Reminder - Impending New Year” ; //Script
“15m” ; //Interval
Get ( FileName ) ; // DB
“It’s Almost a New Year!” ; //EventValue
“12/31/2006 1:00:00 PM”; //StartDateTime
True //Repeat

The above code would start triggering the script “Reminder - Impending New Year” on December 31, 2006 every 15 minutes. The script “Reminder - Impending New Year” could display your script parameter, “It’s Almost a New Year!” in a custom dialog. Further, the dialog could ask if you wanted to continue the alert or cancel it. If you wanted to continue it, no further action would be needed. If you wanted to cancel it, you could use the MMScript_CancelScriptEvent function as follows:

MMScript_CancelScriptEvent( “New Years” )

Do not worry, canceling the “New Years” event will not actually stop the new year from arriving. ;-)

Enable and Disable Script Events

From time to time, you may find that you need to completely turn off events, usually for maintenance purposes.

To disable script events, use the MMScript_DisableScriptEvents function. This function has no parameters and can be used as follows:


To enable script events, if they have been disabled, use the MMScript_EnableScriptEvents function as follows:


Event Information

You can gather information about the last script event triggered by MMScript. For example, you can use MMScript_GetScriptEventName to get the Event Name of the last trigger. You can also use MMScript_GetScriptEventValue to get the value of the last trigger. MMScript_GetScriptEventValue is equivalent to using FileMaker’s built in Get ( ScriptParameter ). The function is really only here to help with legacy calculations from our classic SCRIPTit product. Using Get ( ScriptParameter ) allows you to create more flexible scripts that can be used from different starting points.

You can get a list of current script events with the MMScript_ListScriptEvents function.

Using XML (Optional)

MMScript used to be part of our classic plug-in named SCRIPTit. SCRIPTit utilized XML for the majority of its settings. To aid in moving older SCRIPTit calculations to MMScript, or if you just like the XML interface better, we have included the MMScript_CreateXMLScriptEvent( XML ) function. For a description of the XML you can use with this function, refer to the MMScript_XML section of the function section.