Schedule Notification |
Schedules the display of a notification dialog on screen (and in the notification center).
Syntax
Schedule Notification[ Select ; Result ; NotificationID ; Delay ; Title ;
Message body ; Action button ; File name ;
Script name ; Script parameter; Switches ]
Options
Select entire contents | replaces the entire contents of a field with the result. If not checked the result replaces the currently selected portion of the field |
Result (error) | an error code |
NotificationID | a unique id for the notification that you can supply |
Delay | the number of seconds to wait before displaying the notification |
Title | the title of the notification |
Message | the message of the notification |
Action button | (optional) the text of an action button |
File name | (optional) the file name where the optional trigger script is located |
Script name | (optional) the name of the script to be triggered when the user interacts with the notification |
Script parameter | (optional) script parameter |
Switches | (optional) this changes the behavior of the notification |
Switches
Switches can be empty or one of these:
-NoSound | shows the notification without a sound |
-ShowNotRequired | the OS may decide not to show it when FileMaker is in front (macOS only) |
Returned Result
Data type returned
Error code
Result
If successful the result is 0. If unsuccessful it returns an error code starting with $$ and the error code. Returned error codes can be:
$$-50 | paramErr | parameter error |
$$-4221 | invalidOSVersion | notifications are not supported on this OS version |
$$-4291 | notificationsNotEnabled | notifications are not enabled in the preferences |
$$-4292 | InitializeErr | notifications could not be initialized |
$$-4293 | scriptWontTrigger | (warning only) the script will not be triggered but the notification will be shown |
Originated in
Troi Dialog Plug-in 7.5
Compatibility
FileMaker Pro 16 to 19
Considerations
You may need to allow FileMaker to show notifications and specify the alert style in the system preferences.
The optional trigger script is run *after* the notification was clicked (on the notification itself or the action button).
Note that on Windows the script will only be triggered when the notification is shown directly (with delay set to zero). When the delay is not zero the notification will still be shown and a warning code $$-4293 will be returned as a result.
If you specify a script to trigger, a multiline parameter is passed to the trigger script, which will be formatted like this:
line 1 the id of the notification
line 2 <button label> or the status*
line 3 1 = if FileMaker was in the foreground ; 0 = in the background
line 4..n the optional script parameter
*status can be NotificationSelected, NotificationNotDisplayed or NotificationNotAllowed.
Notifications require macOS 10.8 and higher or Windows 8 and higher.
Example
Schedule Notification [ $ErrorCode ; "note123" ; 10 ; "Time is up" ; "Your egg is ready!" ) ]
This will show this notification after 10 seconds.
Example 2
Create the following script:
# First fill in what you want in variables:
Set Variable [ $NotificationID ; Get ( UUID ) // set this to an a Universally Unique Identifier (UUID) ]
Set Variable [ $DelaySecs ; 5 ]
Set Variable [ $Title ; "Notification with Troi Dialog" ]
Set Variable [ $MessageBody ; "The notification with Troi Dialog was a success!" ]
Set Variable [ $ActionButtonLabel ; "Show me" // is optional ]
# Set the trigger script, which is run *after* the notification was clicked.
# If notifications are disabled for FileMaker, the script still runs at the scheduled time.
Set Variable [ $FileName ; Get ( FileName ) ]
Set Variable [ $ScriptName ; "TRIGGERSCRIPT1" ]
Set Variable [ $ScriptParam ; "Extra parameter info is found here" ]
# Now Schedule the notification:
Schedule Notification [ $ErrorCode ; $NotificationID ; $DelaySecs ; $Title ;
$MessageBody ; $ActionButtonLabel ; $FileName ; $ScriptName ; $ScriptParam ]
This will show this notification after a 5 seconds delay. The script “TRIGGERSCRIPT1” will be triggered after the user clicks on the notification or the “Show me” button. In the trigger script you can for example show the user a specific layout. The script parameter will look like:
8EC4A642-07AE-400C-85D8-3FD5716555D8
NotificationSelected
1
Extra parameter info is found here
Example 3
This example is for macOS only.
Schedule Notification [ $ErrorCode ; "note345" ; 15 ; "Time is up" ;
"Your report is ready!" ; "Show it" ; Get ( FileName ) ; "ScriptToTrigger" ; "-ShowNotRequired" ]
By adding the switch “-ShowNotRequired”, this notification will be shown after 15 seconds, but only when FileMaker is in the background. The notification will always be added to the notification center. The script will still trigger and have as second line in the ScriptParameter the status: “NotificationNotDisplayed”.
Used in example file
Notifications.fmp12
Related script step
Remove Notification |
Related function
Dial_ScheduleNotification |
Related topics
Troi Dialog Plug-in online help (overview)