CNS Plug-ins

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.