2 Replies Latest reply on Jun 25, 2013 7:41 AM by StevenM

    Calling Script from Web Viewer

    gkhaselev

      Hello everyone,

       

      I have written a short line of code as a custom html in the web viewer such that when the link present in the web viewer is clicked it runs a particular script in the file with a parameter. It looks like this:

       

      "data:text/html," &"

      <html>

      <body>

      <a href='"&"FMP://" & Get(SystemIPAddress)

      &"/"& Get ( FileName )& "?script=<scriptName>&param=" & <someField> &"'>View Map Detail</a>

      </body>

      </html>"

       

      Now I know that this web viewer is doing what i want it to do. upon clicking the link the script is executed with the appropriate parameter. However each time the link is clicked filemaker reopens the file that i am trying to work with and asks me to reauthenticate and then runs the script. The functionality i want is for the link to be clicked in the web viewer and the script to run in the same (currently open) file.

       

      in case it helps, sharing is turned on, and when the script runs it reopens the file with the title: FileName (ComputerName)

        • 1. Re: Calling Script from Web Viewer
          Malcolm

          I have written a short line of code as a custom html in the web viewer such that when the link present in the web viewer is clicked it runs a particular script in the file with a parameter. ... each time the link is clicked filemaker reopens the file that i am trying to work with and asks me to reauthenticate and then runs the script. The functionality i want is for the link to be clicked in the web viewer and the script to run in the same (currently open) file.

           

          That's right. The fact that you have logged in via FMPro is irrelevant. The call to run the script is coming from an unknown user via the web. Your file has authentication settings and it wants to know who is waking it up and asking it to do some work. You want to pass a user name and password along with the URL. Check Help to see how to do that. You might consider making a special user account just to run the script.

           

          malcolm

          3 of 3 people found this helpful
          • 2. Re: Calling Script from Web Viewer
            StevenM

            The second window appears because you are sharing the file and is an issue that I have come across and not found a solution too other than hosting the file on FileMaker Server.

             

            What I believe is happening is when you click the web link you then access the same database over the fmapp security privilege which FileMaker will treat as a new instance of the database resulting in a new window.

             

            Look at the script menu from the new window, does it have an IP? Then look at the scripts window from the original window.

             

            I'm pretty sure one will have an IP (the shared IP) and the other will not.

             

            You don't have this issue with FMGo becuase you can explicitly say use this file by this "fmp://~/DatabaseName.fmp12" but this doesn't work on the FileMaker Pro.

             

            You may be able to have an OnOpen script trigger that determines if being called from fmapp and handle the window appropriately.