Tags:

    Running JavaScript from FileMaker

    ReactorJSrun allows you to execute some JavaScript inside a web viewer. You might use this to update the display without completely reloading the BlackBox - for example, in the DayCalendar you can use ReactorJSRun to update the display of an appointment after changing the value of, say, the start time.

    • Runs a javascript function (or the code in the parameter) in the webviewer with the objectID.
    • This function can only be called in the context of the layout that the web viewer is located - i.e, in a script while that window is in front, or in a web viewer calculation. This will not work from a calculation field, or auto enter calculation. Beware: It will not run from the data viewer while you have the calculation window open!!
    • Returns a value on the Mac only.


    Function ID
    Name ReactorJSRun
    Prototype ReactorJSRun( webviewerObjectID ; javascript )
    Return value The result of the javascript run (may be blank if the javascript doesn't return a value).


    As mentioned above, there are a few different places you can run a JavaScript function. For example, to run a javascript function in a script by adding a 'SetVariable' script step:

    SetVariable[ $$com.reactorize.jsrunresult ; ReactorJSRun( "WebViewerName" ; "JavascriptToRun()" ) ] 

    Alternatively, you can run this javascript from within the web viewer by using a field as a trigger. Whenever the value of the trigger field changes, the ReactorJSRun will be triggered.

    Let(
    $$com.reactorize.jsrunresult = Evaluate( "ReactorJSRun( \"WebViewerName\" ; \"JavascriptToRun()\" )" ; Table::TriggerField )
    ;

    MyBlackBox(
    /* The BlackBox function parameters */
    )
    )

    You can run any javascript code on any web viewer with this function, but there are a few gotchas - for example, you need to be aware that in all BlackBoxes, there is a 'setup' phase that occurs while the BlackBox is loading - usually, you won't be able to use ReactorJSRun while the BlackBox is still in this loading phase, but in most cases it shouldn't be a big problem.


    Currently, we haven't got much documentation on the functions you can call with ReactorJSRun, as they are different with each BlackBox. Until we improve our documentation, you can search through the BlackBox Source code to find functions that you can call, but this will require a basic/intermediate level of understanding in JavaScript.