Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

JS.AddFileMakerRunScriptFunction

Adds a function to start scripts from JavaScript.

Component Version macOS Windows Linux Server iOS SDK
JavaScript 10.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "JS.AddFileMakerRunScriptFunction"; JSRef; Name )   More

Parameters

Parameter Description Example
JSRef The JavaScript reference number. $js
Name The name of the function. "test"

Result

Returns OK or error.

Description

Adds a function to start scripts from JavaScript.
Scripts are queued and run later when JavaScript finished.
The function in JavaScript returns the error code from FileMaker, which is zero for success.

For increased security we prefer all FileMaker developers define their own function name, so if you get some foreign JavaScript, it can't know the function name and mess with FileMaker. Be aware that this function may launch any script in the solution, even those not shown in the menu.


With plugin version 6.0 or newer the script name can be a script ID number. In that case the plugin queries the script name for the given script ID. This allows to call scripts by ID and avoid problems if scripts are later renamed.

Notice: FileMaker 19.2 adds a fmplugin extended privileges. If you have such an extended privileges to allow the plugin to trigger scripts, you need to grant permissions for it. If such a privilege is not defined, the plugin is allowed to trigger scripts. See FileMaker product documentation for details.

Examples

Run a script from JavaScript:

Set Variable [ $js ; Value: MBS( "JS.New" ) ]
Set Variable [ $r ; Value: MBS( "JS.AddFileMakerRunScriptFunction"; $js; "FMRun") ]
Show Custom Dialog [ "Result" ; MBS( "JS.Evaluate"; $JS; " \"start script: \" + FMRun(\"JavaScript.fmp12\", \"testRun\", \"Hello World\")" ) ]
Set Variable [ $r ; Value: MBS( "JS.Release"; $JS ) ]

Create JavaScript enviroment with function to trigger scripts:

Set Variable [ $$JS ; Value: MBS("JS.New") ]
Set Variable [ $r ; Value: MBS( "JS.AddFileMakerRunScriptFunction"; $$js; "FMRun") ]

See also

Example Databases

Blog Entries

This function checks for a license.

Created 7th December 2019, last changed 13th June 2021


JS.AddFileMakerEvaluateFunction - JS.AddFileMakerSQLFunction