Cluster Maps Update – Running URL Scripts in a Web Viewer

A reader’s suggestion prompted me to try a powerful technique I have been wanting to experiment with: two-way communication through the Web Viewer. By that, I mean sending a calculated link into some HTML in a FileMaker Web Viewer via a script or calculation. Then with the Web Viewer displayed, the user clicks on the link to search for a record back in FileMaker.

The example I am going to demonstrate involves a map with pin points representing customers or vendors. Clicking the pin causes a FileMaker script to run, bringing up a more detailed view of the customer information. I could imagine it employed in an airplane, restaurant or theatre seating plan. Generate the map from FileMaker, click on a the map to drill down back into FileMaker.

This technique became possible in FileMaker 12 because of the changes they made to allow a URL script callback into the database.

First a simple example, which hopefully will explain the basics of what is going on. Then a more advanced script where the calculated link is inserted in the Cluster Maps information box for each record.

If you want to jump right in and try it out, click here to Download Demo File. If you have any problems with the demo, check the Troubleshooting section at the bottom of the posting.



As I hope to demonstrate, this moving information and links in and out of a Web Viewer is a very useful technique. I have been meaning to experiment with it since the August 2012 FileMaker DevCon in Florida when I saw Vince Menanno’s Inspector ProInspector Pro is a FileMaker Pro Database that will query your complicated solutions and find errors.

Check out the Database Design Visualized feature (pictured above) in Inspector Pro. Each data point, which is generated in a Web Viewer by a FileMaker calculation or script, can be clicked on to zoom into some aspect of your FileMaker Pro solution. This is all done in a FileMaker Pro Web Viewer, using a similar technique and some elegant Javascript. 

Project Overview


1) Simple Example – a calculated Web Viewer


Search window displays


Clicking on the Web Viewer link launches a script that searches for a specified record. The record ID is passed via a script parameter.

Simple link Web Viewer in Layout Mode


Definition of Simple Web Viewer


Data URL


What is going on here? Let’s break it down a little bit.

The header, data:text/html is the method to display FileMaker generated text in a Web Viewer

The link itself is wrapped in an HTML body tag set.

Next is a standard HTML web link. When it is calculated, it includes the IP address, database name, script name and a script parameter, which is simply the record ID.

The calculated URL is FileMaker’s URL scheme for running FileMaker Pro scripts from a web browser. If you paste the result of this calculation in Safari or IE, your database will open and perform the search specified.


Copy the URL above and edit in your own information, substituting in your IP address, a database name, a script name and a parameter for the script.

The Open-Detail-Map script


This simple script searches on whatever ScriptParameter it has been passed. It then opens a new window with the selected record displayed in Google Maps.

The Map Web Viewer calculation


This calculated Web Viewer will display a Google Map location for the address of the current record.

A second copy of the Database has been opened by the script


Note what is happening when the script runs and the new window opens with the map detail, is that another copy of the database is opening. If you look in the top bar of the new window, you will see a (2) tacked onto the end of your database name.

What happens if you try to close the first database instance


When deploying this in the ‘real world’ you may want to lock the popup map window and force the user to close the window before proceeding to avoid them seeing something like this when they attempt to close the first window without closing the other windows first.

This simple example is not very useful; obviously you can write a script to open a window and do a search and simply attach it to a FileMaker button. Let’s move on to a more complex example that demonstrates how this can used in a more advanced setting.

2) Complex Example: Setting the calculated Web Viewer links in a script


In a more advanced script, where the calculated link is inserted in the Cluster Maps information box for each record, we start by modifying the main ‘Generate JSON, HTML and Display Map’ script.

Add a Step to generate a calculated link URL


Using the Set Variable, we create the calculated link. This variable is then added to the next Set Variable step which is calculating the information box that popups up when clicking on the pins displayed on the map.

Calculated URL to add to the info text on the pin map


$infoURL script step: The calculation used is similar to the one used in the Simple Example above, but is simplified to just the a href link components. Note that it is using single quotations to avoid breaking the HTML/JSON file that goes to Google’s Map API.

This variable is then added into the info box in the next script variable $info.

Run the new script “Generate HTML File and Display Map”


Click to refresh the map with the new links added to the Info box that hovers when a pin is clicked on.

Select view in FileMaker’s Web Viewer

The links will also work from the Browser, opening the window back in FileMaker. But for the purposes of this demo, the focus is on the Web Viewer interaction.

Click on one of the pin map items


You may need to ‘drill down’ into one of the clusters to find a red single address pin.

1) click on a pin
2) click the ‘View Map Detail’ link in the popup info box.

New window pops up with the search from the Web Viewer


Now you have two way interactivity with the Web Viewer. You can put informational links in the Web Viewer that can be clicked on to ‘drill down’ for more information in FileMaker. Instead of another Map, this could just as easily bring up a more detailed view of information on a customer, or a set of photos stored in the database. Think of the possibilities…



If you find this technique is not working with your copy of FileMaker Pro 12, here are some things to check:

  • Make sure you are up to date with FileMaker 12.0v3 or higher
  • If you are a developer and still working with both FileMaker 11 and 12, quit FileMaker 11 and then re-launch FileMaker 12. One problem I had involved having FM 11 open and hogging the sharing Port. 
  • Check to see if the demo database has Network Sharing turned on.

FileMaker Go

My initial testing suggests this technique will not work as a standalone file on FileMaker Go, because it can not host files. If the file is hosted, there may be a way to get it to work, but I am still testing. 

Update 2013-06-19: Prompted by commenter Jared Hague on LinkedIn, I went back to work on getting the demo working on the iPad. The simple example seemed to work after I changed from an IF statement to a CASE statement. The longer example required some changes to the file path so that FileMaker Go could find the export file to display in the Web Viewer. I added a global variable called $$Platform that is set when the database is opened (see the On Open script). Then in the ‘Generate JSON, HTML and Display Map’ script, I added this override to the $localPath variable.

If($$Platform=”iPad”; Get(DocumentsPath) & Settings::gFile_Name ; $localPath)

FileMaker Server

To make this technique run on a server, switch the calculated URL link to get(HostIPAddress) from get(SystemIPAddress).

Closing Notes, Tips, Caveats and Thanks

These examples are designed to work on a single file solution not hosted. There will be changes needed if the database is to be hosted on FileMaker Server. Keep an eye on what goes on in your On Open script, you may need to filter for hosted/not hosted status.

Passwords are an issue I have not dealt with. In all likelihood, your system will include the use of passwords. To get this technique working you will need to hard code a user name and password into the URL string. Not the most secure approach, but one idea would be to create a low level user with view only privileges. More thought is required in this area. 2013-07-08 According to Cris Ippolite of iSolutions, login credentials are not required when the script is running within the same session. 

As noted above, when the new window opens from the URL string search, it is opening a second copy of the database. If the host system is the same computer, the newly opened window will have to be managed, perhaps a paused script with a close button to keep the user from being confused when attempting to close the first window.

Some other examples of the FileMaker Pro 12 URL scheme are:
Go Launch  using the URL scheme to open a FileMaker Go on an iOS device.
CNS Barcode bar code reader that integrates with FileMaker Go.
Real World Web Service book info database using URL scheme.

FileMaker 12 Help – Syntax to run a script in a shared database using a URL

FileMaker Go and HTML – Blog posting from iSolutions covering URL scheme topic.

Thanks to Joshua Paul at Neo Code Software for assistance in figuring out how this feature works.

Thanks also to Mike Goldstein of (HMC-PMB) for his suggestion about adding Instant Web Publishing (IWP) capabilities to the Cluster Maps database demo. This prompted the whole discussion above.

For a simpler FileMaker Pro 10-11 version of the Cluster Maps database, see the previous blog entry on Cluster Maps. The demo for that posting has been recently updated to deal with Google’s API change to Version 3.

Update 2013-06-25 – Updated Demo File. Fixed a bug in the Get Coordinates script. Filtering on the number string and managed to leave out the number 8. I figured 8 doesn’t get used that often and how much could it throw things off?

Also, thanks to reader Henry Rose of MacWizard, discovered that Google returns inconsistent JSON files, so adapted the parsing to narrow the focus on the most accurate Longitude and Latitude numbers of the three returned.

Also realized that the Web Viewer on the Map Detail layout was using a calculated address lookup URL rather than a longitude/latitude search. Switched to the more accurate long/lat search.

Added a Show on Map button to view single searches in a web browser.

Ported the Perimeter Search feature to the FM 11 demo from the FM 12 demo. It seems to work, but behaves differently, haven’t figured out why, but sometimes will deliver a different number of locations. May need more refinement.

Update 2013-07-08 – Click here to view a Youtube video of Cluster Maps file in action done by iSolutions, modified to display dollar value totals for a market area, instead of a simple count of markers. Looks like the folks at iSolutions have also modified some of the structure of the demo file to bring the markercluster Javascript ‘in-house’ and expose the function of what data is displayed on the pin map.

Also for some great ideas about running URL scripts from with a Web Viewer check out iSolutions dedicated web site about using HTML 5 and FileMaker Pro. Cris Ippolite of iSolutions has done a whole series of videos on the topic on the iSolutions YouTube channel.

Related Articles

Cluster Maps – Update – Fixed Popup Formatting Bug


  1. Cluster Maps Update – Running URL Scripts in a Web Viewer | Filemaker Info - June 19, 2013

    […] See on […]

  2. Cluster Maps Continued: Perimeter Search in FileMaker Pro 12 | HomeBase Software - June 21, 2013

    […] on a presentation for a customer that employs the Cluster Maps concept, the request came up about doing perimeter searches—as in ‘How do I see all the related […]

  3. Cluster Maps Update – Running URL Scripts in a Web Viewer | Homebase Software | Filemaker Info - July 8, 2013

    […] See on […]

  4. Cluster Maps and Instant Web Publishing | HomeBase Software - August 12, 2013

    […] reader asked how to make the Cluster Maps demo database work with Instant Web Publishing. A little bit of research in the documentation for […]

  5. Running FileMaker Scripts from Your Desktop with Launchy or Alfred | HomeBase Software - September 12, 2013

    […] will result in a duplicate window being opened and you are required to do a second log in. See previous blog posting about how the URI scheme works with locally hosted […]

  6. Mapping Directions from FileMaker Pro with Google Maps | HomeBase Software - February 3, 2014

    […] Cluster Maps Update – Running URL Scripts in a Web Viewer […]

%d bloggers like this: