6 Replies Latest reply on Nov 18, 2016 11:25 PM by NateBrock73072

    Filemaker Server 15 WebDirect Javascript Button Triggering




      I am working on migrating from filemaker server 12 with IWP. I currently use it on some iPods through safari.

      I am able to call a javascript function that correlates to a button on the layout to process a barcode scan.


      Example of that code:


      function iwpExecute(){





      The 176 references a number assigned to the button on the layout.


      Calling this function in a webviewer worked perfectly for 5 years now.



      Moving on:


      Filemaker 15 Webdirect doesn't have a clear cut way of processing a script from javascript.

      I tried the http://wwww.example.com/fmi/webd#MyDB?script=Test

      This doesn't always take and it will frequently ask for a username and password over and over again.

      Which end users would hate.


      I would like to trigger the button with a javascript function to proceed processing.

      But Webdirect uses a ton of eventlisteners, but the one that gets triggered is an anonymous function with random letters and values in a return function. I tried .click() events, mousedown, mouseup, click simulations on the button( ref by element id) BUT NOTHING WORKS.


      Any advice on making a script in Webdirect run via javascript or otherwise but in a clean worry free manner?


      Thanks All!

        • 1. Re: Filemaker Server 15 WebDirect Javascript Button Triggering

          FileMaker GO now scans barcodes natively.  You could run your IWP layout in FileMaker GO instead and just use the "Insert from device" script step.

          Bar code scanning with FileMaker Go | FileMaker


          Alternatively if you need to get JavaScript to call a script in FileMaker then you could make your JavaScript function call a PHP page, and the PHP page could execute the script.

          • 2. Re: Filemaker Server 15 WebDirect Javascript Button Triggering

            You might also look at the idea of running the JS in a webviewer inside Web Direct (browser in browser). The JS source files need to be on the FM web server, but this should allow you controlled interaction with the JS without the page wanting another login.


            Some examples I have seem with the libraries as text objects on the layout fail to render, but that might be due to some error that can be fixed.


            Web Direct in a web viewer inside Web Direct does not work. I tried. You cannot access any FMS page including admin panel from a WV in web direct. FMP works. Maybe this should work.


            There are examples of interacting with JS in a web viewer out there for WD. Geist, and SeedCode have some examples I think.

            • 3. Re: Filemaker Server 15 WebDirect Javascript Button Triggering

              Our warehouse scans 1000s of barcodes a day. The photo capture scanning really wouldn't be fast enough or something workers would be willing to use. Thanks for the suggestion though. We use the ipcprint.com LineaPro 4 scanners on iPods. Some iPods don't have cameras anyways.

              • 4. Re: Filemaker Server 15 WebDirect Javascript Button Triggering

                I tried this in a web viewer and nothing happens. Any suggestions or links I should research?

                • 5. Re: Filemaker Server 15 WebDirect Javascript Button Triggering

                  The camera is too slow and unpredictable for high volume scanning, sometimes it's near instant and other times it can be a while before the camera focuses.


                  Below are three options:


                  1 - You could call a script via a script trigger or button in webdirect.  That script can call the "Insert From URL" script step to run your script.

                  Opening shared databases remotely using a URL | FileMaker


                  2 - Webviewers work fine in FileMaker GO so your IWP layout may work fine in FileMaker Go as it is.


                  3 - The fastest way (depending on your workflow) is to make an AJAX call to PHP to run the FileMaker script.  AJAX will make the call to happen in the background on the iPod and won't hold up your user interface while the script processes on the server.

                  • 6. Re: Filemaker Server 15 WebDirect Javascript Button Triggering

                    Here is what I ended up doing:


                    1. Load Custom JS into jwpc.jar used by Web Direct Engine/Tomcat


                    2. Directory of the  jwpc.jar is in = C:\Program Files\FileMaker\FileMaker Server\Web Publishing\publishing-engine\jwpc-tomcat\fmi\WEB-INF\lib



                    A. The key html code in jwpc.jar is:

                    (Change JWPC.jar to JWPC.zip, extract)

                    Navigate in folder to:




                    I need to add some barcode scanning scripts from LineaPro

                    A.1) Ensure the Infinite Peripherals Javascript in loaded in.

                    A.2) Ensure the BarcodeData function exists.

                    A.2.1) Loop will find special character ~ this will delimit the scanned data

                    A.2.2) Submit the scanned data into url script and post



                    3. Ensure there is a script that runs in filemaker to look at Trigger Field.

                    The trigger field will be on a install on timer script that will constantly look for changes.

                    I just use the Scanned Data to start script.



                    **Always restart the FM Publishing engine if modifying the AppJavaScript.js File**

                    Stopping it before modifying it would be best.



                    **This JS file boots into every publishing engine page**


                    My example script parsing the Web Direct HTML to find my scanned data field.

                    Then I post my scan to the Trigger field with AJAX behind the scenes of the actual Web Direct Page.


                    function BarcodeData(b)



                      var i = 0;

                      var x = 1;


                      while (x = 1) {

                      var PID = document.getElementsByClassName("inner_border")[i].getElementsByTagName("div")[0].textContent;

                      var y = PID.substring(0, 1);

                      if (y == "~") {





                      var urlv = 'http://[your domain]/fmi/xml/fmresultset.xml?-db=JQ&-lay=JQ&-script.prefind=SetTriggerField&-script.prefind.param='+b+'|'+PID+'&-findall';



                      var xml = new XMLHttpRequest();

                      xml.open('POST',urlv, true, 'admin', 'admin');