Jump to content
Salesforce and other SMB Solutions are coming soon. ×

The FileMaker.PerformScript function in FileMaker 19


Recommended Posts

  • Advertiser

You may have read the documentation about the new JavaScript integration in FileMaker 19. Let's take a look on this in detail. For every website you load, FileMaker injects automatically a little JavaScript when the page is finished loading. The JavaScript for the PerformScript script in the FileMaker namespace looks like this:

function PerformScript(name, parameter) {
    if (parameter == null) {
        parameter = ""
    var message = '{"command": "PerformScript", "value": { "name": ' + quote(name) + ', "parameter": ' + quote(parameter) + '}}';
    // For mac
    if (window.webkit && window.webkit.messageHandlers.fm != null) {
    } else if (window.external != null) {
        // For windows

As you see for MacOS (and iOS), they use the MessageHandler protocol offered by WebKit, which is the same we use for our WebView.AddScriptMessageHandler function in MBS FileMaker Plugin. The message handler is quotes the given parameters, builds a JSON text and passes this to the message handler. 

If you need, you can use MBS FileMaker Plugin to add the same functionality for MacOS and iOS (iOS with FileMaker iOS SDK) to your solution for FileMaker 16 to 19. Use WebView.RunJavaScript to install the FileMaker object with the function above. You may need to add a file name parameter as we need that for the plugin to call a script. 

For Windows, the use the external messaging, which is available in Internet Explorer control. Sadly we can't access this via plugin interface for our plugin. But a great move by Claris to add this for us!

Now you may notice that the function checks whether window.webkit.messageHandlers.fm is defined, so if the message handler is not yet installed, the calls to PerformScript do nothing. But you may be able to check whether FileMaker is not undefined like this:

if (typeof(FileMaker) != "undefined") { /* okay */ }

In your JavaScript on the website, you may just run setup work on start and set a timer to do any call to FileMaker.PerformScript a few milliseconds later.
You may want to checkout onfmready.js from Stephan Casas, who made a nice utility function to delay the call until FileMaker.PerformScript is available. See also community posting.

See also Check out options for FileMaker JavaScript Integration

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

Terms of Use