Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
9.3
9.4
9.5
10.0
10.1
10.2
10.3
10.4
10.5
10.6
Statistic
FMM
Blog
JS.CallFunction
Calls a global function given the name.
| Component | Version | macOS | Windows | Linux | Server | FileMaker iOS SDK |
| JavaScript | 10.0 | Yes | Yes | Yes | Yes | Yes |
Parameters
| Parameter | Description | Example |
|---|---|---|
| JSRef | The JavaScript reference number. | $js |
| Name | The name of the function. | "test" |
| Parameters | JSON to pass as parameter. |
Result
Returns JSON or error.
Description
Calls a global function given the name.Parameters are passed to the function. Please pass as many parameters in FileMaker as needed.
If the function needs more parameter, undefined values are used to fill up.
If the function needs less parameters, additional ones are dropped.
Returns the result of the function converted to a JSON value.
Examples
Define a function and call it:
Set Variable [ $js ; Value: MBS( "JS.New" ) ]
Set Variable [ $r ; Value: MBS( "JS.AddFunction"; $js; "adder"; "function (x,y) { return x+y; }" ) ]
Show Custom Dialog [ "Result" ; MBS( "JS.CallFunction"; $JS; "adder"; 3; 4 ) ]
Set Variable [ $r ; Value: MBS( "JS.Release"; $JS ) ]
Concat strings:
Set Variable [ $js ; Value: MBS( "JS.New" ) ]
Set Variable [ $r ; Value: MBS( "JS.AddFunction"; $js; "Concat"; "function (x,y) { return x+\" \"+y; }" ) ]
Show Custom Dialog [ "Result" ; MBS( "JS.CallFunction"; $JS; "Concat"; "\"Hello\""; "\"World\"" ) ]
Set Variable [ $r ; Value: MBS( "JS.Release"; $JS ) ]
Call a function:
If [ Length($$js) > 0 ]
Set Variable [ $p ; Value: MBS( "JSON.CreateString"; test::Input) ]
Set Field [ test::Output ; MBS( "JS.CallFunction"; $$js; "crc32"; $p ) ]
End If
See also
Example Databases
Blog Entries
- FileMaker and JavaScript - the perfect combination
- New in the MBS FileMaker Plugin 10.0
- CRC function in FileMaker using JavaScript
- Our JavaScript engine for FileMaker
Created 7th December 2019, last changed 29th October 2020
Feedback: Report problem or ask question.
Links
MBS Xojo Plugins