DayBackForFileMaker

Custom Actions

Overview: What Are Custom Actions?

Custom actions let you add your own buttons to the calendar. These buttons run your own FileMaker scripts and are a great way to extend the calendar's capabilities.

Each source gets its own action buttons, and our sample events table comes with two: one to jump to the event's record in its own FileMaker layout, and another to just show a simple dialog.

Reveal the actions drawer by clicking the gear icon in the lower right of the event's popover. You can add as many custom actions as you'd like: your list of actions will scroll if it exceeds the length of the drawer.

Here's an overview of how the work along with some tips for extending our example actions and making your own:

http://youtu.be/N8TtttLL5AY

How to Create Your Own Actions

You'll define your action buttons by editing the script "Load Source Settings at Startup...". For each source in that script you'll see a variable called "$sc_CustomEventActions". The definition of that variable declares the names of your action buttons and the names of the scripts they should run.

This takes the form "Button Name<comma> Script Name". Here is the $sc_CustomEventActions definition for the popover shown above:

List (
"View Event Record, Go To Event Record From WebViewer";
"Sample Custom Action, Custom Action Example" ;
""
)

This means that DayBack will draw an action button named "View Event Record" and when it's clicked it will call the FileMaker script named "Go To Event Record From WebViewer". The third item intentionally left blank is a "Watch For Event Changes" option. This can be set to True or False. In most cases this is unnecessary and will complicate your scripts so we recommend to leave the third parameter blank. An explanation of this feature is lower in this article.

Note that you can change the text at the top of the drawer ("Call your own scripts") to anything you'd like by adjusting the calendar's translation file.

Tips for Writing Your Action Scripts

Take a look at our example script "Go To Event Record From WebViewer". That shows you the variables you'll have access to.

Notice also how you can call the script "Find Event by ID (ID)" to jump to your event by passing in the variable $eventID as a script parameter.

The scripts you call with custom actions will have access to a few local variables you can use to find events and manipulate them. These variables will already be declared when your script starts to run:

$start: the starting timestamp of the event you clicked on. For example "10/28/2014 12:15:00"
$source: the number of the source from the event you clicked on. For example, if the event was mapped on the "Source No 1" layout the $source would be "1".
$eventID: the primary key (unique id, often a serial number) or the event your clicked on. This is the from the field specified by "id" in the calc "DBk_WebViewerSource".
$end: the ending timestamp of the event you clicked on. For example "10/28/2014 12:15:00"
$allDay: true or false if the event is an all-day event (an event with no start time).
Please note that the $start and $end parameters will be in whichever date format you are using in the calendar. If you have left the date format settings in their default state this should be your local date format.

Watch For Event Changes

This is the third option when creating a custom action in the "Load Calendar Settings" script. Generally this will be left blank. If this is set to True it will signal the WebViewer to pass back a $queryID parameter to your custom action script. This way each process gets it's own ID. This was also intended to be used for signaling when an event might be updated but we have better methods for that now. Specifically you can look at the "Close Event Window & Refresh Calendar" for updating an event in the WebViewer once it has been edited in a FileMaker record.

Need to run scrips in web apps instead of FileMaker Scripts?

You can use your FileMaker scripts to call urls in other apps--as we do in this example linking DayBack Calendar to your wiki--or you can use JavaScript to talk directly to other apps: Check out JavaScript Custom Actions.
(855) SEEDCODE
support@seedcode.com
Follow us: