AnsweredAssumed Answered

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

Question asked by tineo on Feb 15, 2011
Latest reply on Feb 15, 2011 by philmodjunk

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

Outcomes