Trigger a script from a link in a web viewer

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…

“data:text/html,
<html>
<body>
<a href=”
&
mydatabase::path
&
“>Run My Script</a>
</font></body></html>”

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.

October 2013 Meeting Recap

October saw our lightest attendance to date – TWO enthusiasts – including the moderator.  Hey, it’s all good.  Tracy is normally very reserved, so enjoyed some valuable one on one attention to her issues.  I always said that if just one member shows up, or even nobody, that the meeting will still go on.  It’s about dedication and commitment.  You can’t develop a FileMaker database without committing to it and seeing it through no matter how hard or lonely it gets.   For me as a developer, the most enjoyable part of the job is listening to a user’s challenges.  Novice users speak in the most innocent and unassuming terms when describing what they want their database to do.  Every wish list item is an opportunity to  find the best solution.  I walked away from this meeting with the spark of an idea to a problem that’s been bothering me for years.  And the following day I solved it.  So October was one of the most enjoyable and rewarding meetings to date.  That’s not to say don’t show up, no no no.  It just means you get out of things what you put into them.

Designated Drivers

Don’t Forget FileMaker Fans,

We have an exciting meeting today at 4pm at La Pietra.  There are two changes to the agenda.

First Change:  Refreshments will be served courtesy of Island Network Solutions, LLC!

Second Change:  I’ll  kick off our “Designated Driver” party by creating an empty FileMaker database.  In FileMaker Advanced I’ll convert it to “KiosK Mode”.  This will make our little community app look much cleaner in FileMaker Go.  Then I will upload it to FileMaker Server.

From that point on, we can all develop the app simultaneously. This experience will show us some of the limitations of co-development or working on a solution while clients are connected. But we’ll also see our work appear before our eyes in real-time!  It also means you won’t be limited to 10 minutes, and not everyone will be watching you work.  Pheew! Pressure off.  It’s going to be crazy and fun.

So bring a laptop with FileMaker Pro 12 or FileMaker Advanced 12.  I’ll bring several laptops with FileMaker 12 to share around.

See you at 4,

Kent

photo

Best Meeting So Far

Noriko, Jesse, Mike, Jordan, Sandi, Milton, Jaye, James, JJ, and several others who arrived a little late.

We had a really great meeting in November, and not just because Milton showed off an iPad Mini.  Jesse Pu’a of In Touch Info Tech systems joined us.  As an IT consultant and solutions and service provider, he’s seen a lot of database systems.  But when it came to deciding on a new system for his own company, FileMaker was the compelling choice.

The format for the meeting was Jesse assuming the role of the “customer”, and the more experienced members of the group took the role of FileMaker “developer”.  We discussed the needs of his database and reviewed the all important design aspects of a good database.  Then we got to work actually building it.

The less experienced members of the group received important training on the fundamentals of good design.  Sometimes we inherit databases from others, and don’t always understand the initial logic used to create it.  By starting a database from scratch, we’re reminded of the issues the initial designers may have faced.

Everyone contributed to the design and development of the sample database.  We kept things simple and stuck to the basics.  Above all, we had fun laughing over the complex and challenging issues that arise even with a seemingly simple solution.

Photo May 01, 4 18 43 PM

FileMaker 12!

Alexi Folger, FileMaker Senior Systems Engineers, points out a powerful new feature in version 12.

Glen Suarez and Alexi Folger were back in town for the May meeting.  Glen explained the new licensing guidelines of FileMaker version 12, and confirmed the fact that FileMaker Go 12 for iOS is a free download from the App Store. With 35 million iPhones and 11 million iPads sold last quarter, the ocean of devices for FileMaker solutions is vast.

Glen Suarez

After Glen’s presentation, Alexi wasted no time wading into the new waters of FileMaker 12.  indeed she could only wade within the short hour and half she had to cover a plethora of new features in both FileMaker Server as well as FileMaker Pro.  New tools for layout themes, alignment, and layout parts.  New tools for charting.  And new tools for storing container data outside of FileMaker at specified directories on the host computer.

 

3rd Meeting A Charm

The focus of the November 5, 2010 meeting was “anchor buoy” relationship graph design.  Eleven attendees relearned an effective way to structure table occurrences in FileMaker’s relationship graph.

Milton’s humble demeanor and unbridled enthusiasm for FileMaker made for an enjoyable and informative presentation. His MacBook Air was pretty cool too.

Milton Shak gave the presentation, building an invoice system from the ground up, stepping through the process of creating a common set of table occurrences for each table in the database.  Sensitive to everyone’s level of experience, Milton made no assumptions about our experience drawing an Entity Relationship Diagram (ERD), and dove right in to how FileMaker handles the concept.  Even the seasoned developers in attendance appreciated revisiting the practice of using a well organized relationship graph.

Look for Milton’s example database and other materials that will be available for download in the Solutions section.

We started the meeting on time as always.  Milton’s presentation took an hour, plus half an hour of Q&A.  We spent the last 30 minutes for open discussion.  Suggestions for our next meeting included best layout design practices, conditional formatting, and script triggers.  It was also proposed that we use the last half hour to break up into focus teams.  Members would bring their laptops and work directly on their issues along side others who are interested or struggling with similar issues.

Stay tuned for the next meeting announcement and agenda.  Until then, have a great FileMaker Weekend.

Dynamic Menu topic posted in Solutions

The details of the main presentation from the Sept 24, 2010 meeting – Dynamic Menus – has been posted in solutions.

Kent is the developer and has access to all layouts.

Brad and Angelina have their own list of layouts allowed by their security group. Each instance of the menu is on the same menu layout, updated dynamically depending on the current user.

This is an advanced topic involving scripts, repeating global fields, the security model, and conditional formatting.  Building the solution had many of us scratching our heads, but the benefits of the end result were obvious and exciting.  Please read through the solution and you’ll find that it’s not that difficult.  The hard parts are provided for you in the downloadable demonstration.

Dynamic Menu – Part 1

Here are the details of the main presentation from the Sept 24, 2010 meeting – Dynamic Menus.

As you know,  FileMaker is a database platform that combines a robust user interface with database tables.  If all you’ve ever used is FileMaker, this fact may not be obvious to you.  If you’ve worked with databases such as Microsoft SQL or MySQL, you know that there is no interface for the end users to manage data in a meaningful way.  You have to create a separate environment using authoring tools such as Visual Basic or PHP and a web server.

Think of the most common “database” – a spreadsheet.  The interface for the information in the spreadsheet is a grid.  There aren’t many tools for structuring the information.  There are tabs for different worksheets, basic cel formatting, unintuitive formulas for calculations, and commands buried in the menus for sorting.  Spreadsheets are a cumbersome environment for designing forms that link data to other parts of the database.

By contrast, FileMaker offers a native method for structuring information.  It’s called the Layout.  Layouts display any information that you choose to place on the layout.  Layout A can be a form that forces the user to enter information in a specific order, and Layout B can be a list of all the forms and the information that was entered.  The information on each form is the same, just displayed differently for different purposes.

That fact that the raw data is displayed on layouts in FileMaker is what makes it an attractive platform for department managers and non-technical users who need a fast learning curve.  It’s also what drives database purists crazy about FileMaker.  SQL guys like the data “abstracted” from the interface so it can be used in any interface authoring environments.  FileMaker data can be used in other interface authoring environments, but that’s a subject for later.

In this group we accept that FileMaker is a pure database engine tied to an integrated user interface system.  Still, we can go a little “layout crazy” when Sally wants a layout that only shows her information and Bob wants a layout only for his information.  We find ourselves making dozens of layouts displaying the same data simply to meet the work flow and security rules.  There’s no way around that if we want to make our co-workers and clients happy.  Why would we force users to interpret information when it’s so easy to make a layout that renders a pleasantly formatted set of fields with buttons to take specific actions from that point in the work flow?  We wouldn’t.

But that doesn’t mean we have to struggle with a long list of layouts and update every previous layout with a new button that navigates to new layouts we’ve placed in the database.  There is a way to create a universal layout navigation menu that automatically updates itself when you add new layouts to the system.  The Dynamic Menu can also change depending on who is logged in.  The purpose of the Dynamic Menu is to save you time as the developer and promote consistency for the users.

Please watch the following video to see how the Dynamic Menu works.

Dynamic Menu – Part 2

Dynamic Menu works by storing the names of the layouts in a global repeating field, and then displaying the numeric instance of the repeating field to generate a series of buttons with titles that match the layout names.  Clicking the button passes the contents of the field repetition to a script as a parameter.  The scripts reads the parameter and goes to the corresponding layout by calculation.

The heart of Dynamic Menu is a script that runs at login to determine what layout names to populate in the repeating menu field.  The layout names that populate the menu names field are filtered by a couple of conditions.  a) does the current user’s privilege set allow them access to the layout.  b) does the name of the layout begin with special characters that prevent it from populating the layout menu.

Let’s get started.

If you don’t already have a table in your FileMaker database for storing system wide data such as preferences, you’ll need to make one.  I like to use the table name “sys” or “prefs”.  In the example I use the table name “!menu” and it contains fields only for managing the dynamic menu.

The menu table contains several fields, but the critical one is “menu”.  It is a global text field with storage options to allow up to 60 repetitions.  The reason that is is global is so that the menu names can be displayed on any layout regardless of the layout’s table.  The reason it is a repeating field with up to 60 occurrences is so that you can have up to 60 layout navigation buttons.  You can have as few or as many as you like.

Now build the display of your menu.  Make a layout called “~menu”.  The tilde will hide the menu layout from the menu.  You’ll see how when we study the login script that filters layout names. Place the “menu” field on your “~menu” layout and use the field format command or inspector (FM11) to show repetitions 1 to 1.  Duplicate the field and move it below the first field and format it to show repetition 2 to 2.  What you are doing is creating buttons that will be titled automatically from the layout names.  You’re using a repeating field so that you don’t have to create fields for every layout name. Repeat these steps until you have a grid of fields organized in order of the field repetitions.  You can align the fields vertically in a single column, multiple columns, or horizontally (as in the header style menu shown in the video).  Just be sure your field repetitions are sequential or else the menu order won’t match the layout order.

I’ll finish this solution tutorial Oct 22-23.

Dynamic Menu – Part 3

The heart of Dynamic Menu is the script that populates the repeating fields with the names of the layouts.

#_________________________________________clear menu
Set Variable [ $MenuCount; Value:60 ]
Set Variable [ $MenuNo; Value:1 ]
Loop
 Set Field [ !menu::menu[$MenuNo]; "" ]
 Exit Loop If [ $MenuNo = $MenuCount ]
 Set Variable [ $MenuNo; Value:$MenuNo+1 ]
End Loop
#_________________________________________set defaults
Set Variable [ $LayList; Value:LayoutNames("DynamicMenu") ]
Set Variable [ $LayCount; Value:ValueCount($LayList) ]
Set Variable [ $LayNo; Value:1 ]
Set Variable [ $LayCurrent; Value:GetValue($LayList; $LayNo) ]
Set Variable [ $LayCurrentMask; Value:Left($LayCurrent; 1) ]
If [ Get(CurrentPrivilegeSetName)="[Full Access]" ]
 Set Variable [ $Masks;Value:"0¶1¶2¶3¶4¶5¶6¶7¶8¶9¶~¶`¶!¶@¶#¶$¶%¶^¶&¶*¶(¶)¶_¶=¶+¶[¶]¶}¶¶|¶;¶:¶'¶,¶<¶.¶>¶/¶?" ]
Else
 Set Variable [ $Masks;Value:"0¶1¶2¶3¶4¶5¶6¶7¶8¶9¶~¶`¶!¶@¶#¶$¶%¶^¶&¶*¶(¶)¶_¶=¶+¶[¶]¶}¶¶|¶;¶:¶'¶,¶<¶.¶>¶/¶?¶{" ]
End If
Set Variable [ $MaskCount; Value:ValueCount($Masks) ]
Set Variable [ $MaskNo; Value:1 ]
Set Variable [ $MaskCurrent; Value:GetValue($Masks; $MaskNo) ]
Set Variable [ $MenNo; Value:1 ]
#_________________________________________start building the menu
Loop
 Set Variable [ $LayCurrent; Value:GetValue($LayList; $LayNo) ]
 Set Variable [ $LayCurrentMask; Value:Left($LayCurrent; 1) ]
 Set Variable [ $MenCurrent; Value:GetValue($LayList; $LayNo) ]
 Set Variable [ $MaskNo; Value:1 ]
#_________________________________________
  Loop
   Set Variable [ $HideLayout; Value:0 ]
   Set Variable [ $MaskCurrent; Value:GetValue($Masks; $MaskNo) ]
   If [ $LayCurrentMask = $MaskCurrent ]
    Set Variable [ $HideLayout; Value:1 ]
   End If
 Exit Loop If [ $MaskNo = $MaskCount or $LayCurrentMask =$MaskCurrent ]
 Set Variable [ $MaskNo; Value:$MaskNo+1 ]
 End Loop
#_________________________________________
  If [ $HideLayout=0 ]
   Set Field [ !menu::menu[$MenNo]; $MenCurrent ]
   Set Variable [ $MenNo; Value:$MenNo+1 ]
  End If
Exit Loop If [ $LayNo = $LayCount ]
Set Variable [ $LayNo; Value:$LayNo+1 ]
End Loop