« Xojo Meeting in Berli… | Home | Transactions in MBS X… »

Run scripts via Data API with FileMaker Plugins

As you may know the FileMaker Server Data API does not load plugins. If you need to run a script using plugins, you need to use a little trick. You query the application version of the script engine running the script. If you get back "FileMaker Data API Engine 18.0.1", you know the script is run via Data API. Now you can branch to the same script on the server scripting engine. That is a different process on the FileMaker Server which does load plugins. Then you return the result back to the calling script. Let us show you an example script:

If [ Position ( Get(ApplicationVersion) ; "Data API" ; 1 ; 1 ) > 1 ]
    # forward call to Server Scripting Engine
    Perform Script on Server [ Specified: By name ; Get(ScriptName) ; Parameter: Get(ScriptParameter) ; Wait for completion: On ]
    Exit Script [ Text Result: Get(ScriptResult) ]
End If

Exit Script [ Text Result: "MBS: " & MBS("Version") & ", Server: " & Get(ApplicationVersion) ]

As you see we forward parameter and get back the result. So without the trick with the if block, we get back from the script:

"MBS: ?, Server: FileMaker Data API Engine 18.0.1"

and with the if loop and our forward:

"MBS: 10.0.0.9, Server: Server 18.0.1"

And you can use MBS Plugin on the server via Data API.

We recommend to check LastError via Get(LastError) function call after Perform Script on Server to see if you got "Hosts capacity exceeded" with error number 812. In that case it may be good idea to make a 10 second script pause and try again.

PS: See also product idea: Support plugins in Data API
16 01 20 - 11:52