We’re continuing our discussion of the new FileMaker 19 add-ons. Claris has released a great video on these add-ons, but, in this series of posts, we’re taking a deep dive into how the add-ons work. In this post we look at how to use the FileMaker add-on refresh feature.
The Point of the Add-ons
In previous posts I’ve mentioned that the discussed feature is the point of the add-ons. I talked about how multiple instances is the point. Refetching the data, and other parts of the add-ons are the point. Maybe there’s too many points, but I’ll add one more. Being able to refresh the add-on’ without any flashing of the web viewer is a win for these add-ons. Let me explain how it works.
The Stale Data
The Fresh Data
These add-ons, however, come with a refresh feature that solves the problem. Any user, including the one viewing the Calendar, can edit a record in various ways. Closing that record or even switching layouts or windows could force a refresh of just the data part of the add-on. The entire code doesn’t have to be reloaded (which is the thing that caused a web viewer flash). Now the newly-changed data can flow into the add-on with no jolt in what the user sees save for the new card to be added or the shade of the heatmap to go darker, whatever the case may be. This feature really turns the add-on into a ‘first-class’ feature of FileMaker; the add-on interacts with data just as a button bar calc or portal or hide calculation does.
The FileMaker Add-on Refresh
Here’s how the refresh works. Each add-on comes with a Refresh script, named after the add-on. The Timer’s script is “Timer Refresh”. Its job is to update the add-on with data from the source table (declared in the config and procured through the find script, if applicable). It takes as a parameter the Addon UUID as a string, collects the data and sends the data to the add-on through a function that begins, often, with the word “update”. You can see it in the script.
That’s how it works. It’s simple.
Tips on Refreshing
The refresh script is there for you, the savvy FileMaker developer, to use wherever you see fit to refresh the data. This script can be called as a trigger, as a subscript, as a parent script on a button. It can be part of updating routines that happen. Let me give you some specific suggestions on using this.
- All you need to do to refresh the data is to run the Refresh script, passing in the add-on’s UUID as a string parameter. Don’t worry about the find mechanism or filter mechanism. This refresh script, or more specifically the JS function that it calls, will do all that finding/filtering for you.
- A sample layout is included for the dashboard-type add-ons. This layout is used as a card window when the user clicks on a card or event or circle in the heat map. The button on this layout that closes the window also runs the Refresh script. Use that model in your work.
- For those record-type add-ons (Timer, Editor, Simple Chart), your refresh should go on a field in which a user types data. Without this, it would take a layout enter to get it to refresh (since the add-on is self booting and gets the initial data).
- Be sure to include as a parameter the add-on UUID, which is found in the add-on itself.
The Difference Between the Refresh and Refetch
We’ve talked about the simple Refetch mechanism found in most add-ons. When thinking about that and the refresh, you might wonder: what’s the difference?
Well certainly they both get the latest data from the source table and push it into the add-on. In that way, they’re the same. But the refetch happens on some add-ons (Heatmap, Kanban, Activity Timeline), and it happens at an uncontrolled interval. To force the refresh of data, you, well, refresh the data. You control the refresh.
The FileMaker Add-on Refresh
This simple feature, something you hook up where ever you want, is one of the most powerful parts of each add-on. You have control over when the add-on is refreshed with new data. So do that: add the refresh and watch data flow at your command to the add-on.