3 Replies Latest reply on Feb 15, 2011 2:39 PM by philmodjunk

    Check for existence of web image to set value of field - how to run this script from FileMaker...

    tineo

      Title

      Check for existence of web image to set value of field - how to run this script from FileMaker SERVER ?

      Your post

      I have a layout with a WebViewer set to show an image from a web server - the url is calculated from fields in the database, something like http://name_of_server.com/public/images/ID_OF_RECORD.jpg - this works, it shows the image when it exists, and shows the "NOT FOUND" message returned by the server when the image doesn't exist.

      Some records have an image that exists and some don't.

      I have a script that scans the records one by one (loop) to check if they have an image in order to set an ImgExist field to Yes or No (needed for displaying only the records that have a picture in a Ruby on Rails web app that uses FmPro as its database). But the scrip refuses to run from the Scheduler of FMS.

      Here is the script :

      Go to Layout ["Gestion Images" (Catalog)]

      Show All Records

      Go to Record/Request/Page [First]

      Loop

      Pause/Resume Script [Duration (seconds): .1) ### disabled step for server run

      Set Field [Catalog::ImgExist; If ( GetLayoutObjectAttribute("web";"content")  ^  "<title>404 Not Found" ; "No" ; If ( GetLayoutObjectAttribute("web";"content") = "<Unsupported Type>" ; "Yes" ; "Unknown" ) )]

      Go to Record/Request/Page [Next; Exit after last]

      End Loop

      The script works when run from a client machine on the local network (remotely the latency of fetching the images in the layout is too great and the script step tests before the image having loaded in the web portal) - of course it's a problem to have to run this from a client machine - I would like to schedule it every-night from the FMS scheduler.

      I know that the Pause/Resume step is not server compatible - but even when disabled, the script returns an error 110 in the log : 

      Schedule "test run check-img-exist" scripting error (101) at "Catalogue : Check if ImgExist : Go to Record/Request/Page"

      Anyone know :

      A. how to run such a script from FMS instead of a client?

      B. a better method to set the value of a field (imgExist to Yes/No) depending on the existence of an image at a web url?

      Thanks a lot for your help !

      Cedric Tineo

        • 1. Re: Check for existence of web image to set value of field - how to run this script from FileMaker...
          philmodjunk

          One way to "pause" without using Pause/Resume:

          # approximate 5 sec pause
          Set Variable [$Time ; Get ( CurrentTime ) + 5]
          Loop
             Exit Loop if [Get ( CurrentTime ) > $Time]
          End Loop

          There are also ways to use the OS to schedule the launch of a "robot file" that performs a script when the robot file is opened. Since this file opens as a client of the server, Server Scheduler limitaions do not apply.

          • 2. Re: Check for existence of web image to set value of field - how to run this script from FileMaker...
            tineo

            Thanks for your pause workaround PhilModJunk

            I don't understand what you mean by 'robot file' that performs a script. Do you mean a shell script or a filemaker script - and launched from where, doing what ?

            Also, if I remove the pause step to the script mentioned in my post, it still doesn't work when launched from FMS' scheduler, there is this 'error 110'. Is it because testing the content of a webviewer is a layout type function and the server can't really do that without a client open ???

            • 3. Re: Check for existence of web image to set value of field - how to run this script from FileMaker...
              philmodjunk

              I would not be suprised to hear that you are correct with regards to this function being incompatible with a server scheduled script, but there's no indication in FileMaker help that it is so we can only speculate.

              Here's an example of a robot file we use to run a script once a night that includes Import Records steps and thus is not compatible with a server scheduled script without making the process needlessly complex:

              We use Windows Server so I use Windows Task Manager to control when the robot file does its thing. I understand there's a similar tool for Mac systems called Chronos--but I'm just going by memory based on another forum user's post.

              I use it to schedule the FileMaker robot file to be opened at a specific time each day.

              In the FileMaker File, I have no tables, only one blank layout and this script:

              Perform Script [//I specify a script in one of the files hosted on the server]
              Exit Application

              This file is defined to open itself with an account name and password that matches an account defined in the hosted file. You do this by creating the account in Manage | Security and then using File Options to specify that the file open itself with this same account and password.

              While in File Options, you also specify that the above script be run when the file is opened.

              In our setup, we can get away with installing FileMaker Pro on the server machine as this script is scheduled to run late at night when there are no other users (Thus no performance "hit"). We also do not use Instant Web Publishing--I think Installing FileMaker Pro on the server might interfere with that.

              If there are issues with installing FileMaker Pro on the server, you can set this up on any workstation linked to the server.