Portage Bay
Portage Bay

Hashtags in FileMaker

With the dawn of social media, hashtags have taken on new form. What was once used for phone calls and code comments has now become commonplace among social media for “tagging” posts. While it’s easy for FileMaker to keep a repository of indexed keywords, FileMaker cannot easily display those keywords in a format that resembles the UI found on most social networks.

Web viewers, in a way, are essentially the “black box” of FileMaker development. There are seemingly endless use-case scenarios for web viewers, but in this example, we’re using the web viewer to display those user-defined keywords in a format that more closely resembles the UI found on most social networks. Download the demo file and follow along:

The keywords can be stored however you wish, but in this case, they are concatenated into a single indexed field. The magic is in the script that creates the html that will be used to set the web viewer. (If you’re new to web viewers, Soliant Consulting did an excellent blog post introducing the basics of FileMaker Web Viewers.)

In the demo file, the script "trig_Refresh Web Viewer Tags” loops through the list of keywords and creates a variable from the href links that will be wrapped with the html elements and used to set the web viewer object. 

Perform a find on the keyword: 
<a href=\"fmp://$/ & Get ( FileName ) & "?script=FindTag&param=" & $tag & "\">" & " #"&$tag & "</a>

Remove the keyword from the “Tags” field: 
<a href=\"fmp://$/" & Get ( FileName ) & "?script=DeleteTag&param=" & $tag & "\">" & "x" & "</a>

The links in the web viewer reference two scripts that perform either a find on the “Tags” field (script “FindTag”) or remove the tag word from the “Tags” field (script “DeleteTag”). With a bit of HTML styling, you can style the web viewer to match your solution, and there you have it: hashtags in FileMaker!

The one caveat for referencing FMP files in a web viewer is, there can only be one copy of FileMaker running on the local machine. When FileMaker is installed (on both Windows and Mac OS), it installs some sort of redirect that launches any URL starting with “fmp://“ in FileMaker, but the version of FileMaker isn’t specified, so it launches the first running version it finds.

For a brief explanation of hashtags, or for a good laugh, check out The Tonight Show host, Jimmy Fallon, and musician Justin Timberlake giving their take on using hashtags.
~Joe Ranne