Since the introduction of the webviewer layout object back in version 8.5, folks have wanted a way to trigger a script by clicking a link in the webviewer.   Why?  Because the webviewer offers so many other ways to display and interact with data.  Here’s a practical example.  Let’s say you have a huge layout covered with fields.  Instead of making the user scroll around, or click tabs, or go to another layout, you want a spot where all the important data is nicely displayed and formatted.  No big deal.  You could do that with another field that combines the important fields into one text block.  Well, what if you wanted to click on a word or phrase in that text block to trigger a script that displays extra details?  You can’t apply a button action to a word in a text field.   But you can apply a hyperlink to a word in an HTML page.

If you google around, you’ll be told that you can’t trigger a script from an element in a webviewer without a plugin, or javascript, or an external html file, or a web server.  But you can.

I wrote a really nice description of the solution on FileMaker Forums, but the site wouldn’t accept any of the code for some reason.  Maybe a copyright thing, I don’t know.  I closed the post before I copied the description.  So I’m not going to rewrite it all here.

I will say that it involves using the “FMP://” hypertext prefix designed by FileMaker to launch a file and run a script from an external source like an email message or web site.  The trick to making it work within a web viewer is to know how host file paths work.

Here’s a teaser:

If you make a calc field called ‘path’ that does this…

“\”FMP://”&Get ( HostIPAddress )&”/”&Get(FileName)&”?script=hello&param=world\”"

and then a webviewer with address calculated to do this…

<a href=”
“>Run My Script</a>

You’ll see a link in your webviewer that will run the hard coded named script along with a parameter.

Come to our next meeting for more about this solution.  Join the mailing list if you want to be reminded about the next meeting.