8 Replies Latest reply on Nov 30, 2013 11:54 AM by carlo.m

    How can I prevent FMP url scripts from overlapping/disappearing?


      I've got a webviewer in a solution. In the webviewer I have javascript that runs several functions. Given some user interaction, with FMP URLs scripts can be triggered. I'm using the window.location=FMP:// method to call the script.


      I came accross an issue. There is a javascript function that has a couple of IF statements, if true it triggers a script via FMP URL. Only the second one goes through to Filemaker.


      After a lot of testing, I was able to infer that the first call to FMP didn't go through, or didn't have enough time.


      How can I fix this? I've thought that maybe running a setTimeout would work, but I'm hoping there is a better way so I don't have to waste a user's time everytime they click a button.

        • 1. Re: How can I prevent FMP url scripts from overlapping/disappearing?

          Not sure I follow... is this an IF ... ELSE IF .... END IF structure in your javascript or more like multiple IF ... END blocks?

          • 3. Re: How can I prevent FMP url scripts from overlapping/disappearing?

            Seems like a bad idea to have one java script call try and execute multiple FM scripts.  Having said that I would not expect it to fail, both scripts should show up in the stack when you have the script debugger enabled.


            Can you change your javascript code so that would only ever call 1 FM script on a user-click?  Remember that you can pass parameters so you FM script can branch internally based on that instead of you doing branching in javascript

            • 4. Re: How can I prevent FMP url scripts from overlapping/disappearing?

              It might initially seem like a bad idea, however I don't believe it is.


              The solution is very robust (complex) and used in a high paced enviornment.


              There are two basic reasons why I decided not to send all commands to filemaker in a single script:

              1) modularity: it is much easier to maintain and expand upon the solution with this flexibility by having chunks of code that do distinct things, much like you have subscripts in FM.

              2) pace of use: the fact that a user might click a button withing fractions of a second of eachother sending separate commands to FM makes me need to solve this problem even if sent all commands to FM in a single script, because separate button clicks would trigger multiple calls anyway.


              My temporary solution was to set up a variable in javascript that checks the time between calls, and makes sure they are at least X milliseconds apart from eachother. What I don't like about this route is that I don't know what call times each machine will take, so under a given circumstance, this option might break.

              • 5. Re: How can I prevent FMP url scripts from overlapping/disappearing?

                Hello Carlo,


                When I read your post I had thoughts similar to what Wim has said.  While I appreciate the modularity offered by what you are doing, I am suspicious of potential log-jams that could happen when the pace of use is fast.


                My sense is that running multiple successive calls using the FM url from the same HTML page could fail due to a subsequent call pre-empting a previous call before the browser has even sent the first request.


                Should this be the case, it isn't the case that FM is failing to act on the first call, it simply so happens that the first call never even happens.


                If you think that this theory potentially has merit, one thing that you might try would be to use a more robust method for calling the URLs.  Specifically, instead of using the window.location method to invoke a URL, you might see how it works out to try invoking the URL via an Ajax type of methodology.  If I were trying this, I think that the first thing I would check out would be the jQuery API documentation for Ajax functionality, and set up a test environment which uses this to trigger the URLs instead of window.location.


                Hope this helps and good luck!








                1 of 1 people found this helpful
                • 6. Re: How can I prevent FMP url scripts from overlapping/disappearing?

                  Hi Steve,


                       I agree that the issue is probably in the webviewer (browser) and not su much in Filemaker. If FM does get the call, it should appear in the stack.


                       AJAX is probably more what I might be looking for. I did some initial tests and was unsuccesful.


                       I was using the MBS plugin to make the calls before having to migrate to the FMP URL. Unfortunately the technique used with the MBS plugin for the MBS("WebView.InstallCallback") function is not compatible with ie10 and the solution must be compatible with ie10...


                       Another issue I found with FMP URL is that it places the called script as the foremost script (just behind the currently running script). MBS set it at the bottom of the stack, which to me is more correct and logical for that type of interchange... So this is causing even more problems with the way the javascript is coded in the solution.

                  • 7. Re: How can I prevent FMP url scripts from overlapping/disappearing?

                    Hi Carlo,


                    Thanks for the further details.


                    In thinking about this today I realized I wanted to run an idea by you:


                    Since you already were working with the MBS plugin, I wonder if you have considered using it in a different fashion.





                    I believe that the MBS plugin allows you to invoke a FM script from within the calculation engine.  As this particular feature is not tied to browser functionality, I suspect that it will be available to you in your environment.


                    In particular, the benefit of this function is that it opens the door to allowing you to retain the modularity of your system which you wish to preserve, while at the same time considering an approach hinted at by Wim's post, namely, having a FM "dispatch" script which is engaged solely for the purpose of:


                       - receiving the click callbacks from the browser/webviewer

                       - queuing up any new requests -- (adding the newest requests to the end of the queue)

                       - dispatching the scripts which are in the queue, starting at the top of the queue, and working down until the end of the queue has been reached


                    The "invoke script by name" type of functionality afforded by using the plugin should allow you to retain your modularity, while being able to implement your own dispatch script might give you the control that you need to be able to mitigate the behavior you've observed with the FMP URL whereby the most recent URL-invoked script jumps to being second in line in the stack.


                    I must confess that I haven't tested this idea for proof of concept -- it is just a thought.  It would definitely take some extra engineering effort to make the exchange between the javascript and the FM dispatch script robust and airtight -- perhaps more effort than it would be worth in the end.  The above-and-beyond effort that I foresee would involve developing a means whereby the javascript could bundle multiple script invocation calls into a single call to the FM dispatch script, and then the dispatch script would need to parse out these calls and also weed out any which are duplicates from previous calls made by the javascript code. In theory, this seems like this could work, but I must say, in practice it starts to sound more complex than what would suit my personal taste.


                    I hope perhaps the above may be useful to you as you work on this and consider various ideas.  Please let me know if I should clarify any of it.


                    Very best and good luck,





                    p.s.  Also, one issue that would require some research would be getting used to how scripts invoked by MBS via the calculation engine wind up queued in the stack.


                    Message was edited by: steve_ssh.  Corrected some spelling errors.

                    1 of 1 people found this helpful
                    • 8. Re: How can I prevent FMP url scripts from overlapping/disappearing?

                      Great ideas Steve, thanks for the input!