3. Introduction to Hooks
Before we continue integrating, let's take a step back to understand the concept of Hooks in BetterForms
What is a Hook Script?
A hook script is a script that inserts itself into normal workflow allowing additional control. See: https://en.wikipedia.org/wiki/Hooking. You interact with your application and the web client via hooks scripts.
BetterForms hooks fall into 2 categories:
Common hooks are scripts that are not contextual to a specific page. Typically they can be called from anywhere and do not contain information about the user's current page. (Eg: A login or registration hook are common hooks.) Common hooks are unified by a Site and therefore configured in the site settings.
Scoped hooks are bound to a specific page. Most of the hook scripts you will use throughout BetterForms will be scoped hooks. Scoped hooks are unified by the form and therefore configured in the form editor.
When do Hooks run?
A hook script can be triggered in a variety of places, here are just a few of the most common examples:
onLogin - a common hook used when a user first logs in to the web client
onFormRequest - a scoped hook that's optionally triggered when a page is first loaded
typically used to push data from FileMaker to the user
using the runUtilityHook **** action anywhere that actions can run
typically used on a button that's intended to save data back to your FileMaker database
For a full reference of all available hooks, see this page:
Script HooksHow to name Hooks
The next few steps will ask you to create names for both a common hook set and a scoped hook set. Here are few tips to keep in mind:
The names of hooks are internal to your application and never displayed to the user
It's best to keep them short but descriptive for easy legibility
Hook names do not need to be unique throughout your site (see tip below)
As long as the names match between BetterForms and FileMaker, everything will work just fine.
FileMaker Analogy
A scoped hook name is referenced similarly to Get ( LayoutName )
in FileMaker. When a script is run, the scoped hook name is used to let your server-side script know the context that the user is sitting in.
This allows you to group scripts that run from the context of the same page together in your FileMaker scripts. Since these name don't need to be unique, you can group multiple pages together by having them share the same scoped hook name and your FileMaker scripts will see them as effectively the same page.
Last updated