Schedule Notification (script step reference)

Troi Dialog Plug-in > Script steps reference > Schedule Notification
Troi Dialog Plug-in for FileMaker Pro

Schedule Notification

Schedules the display of a notification dialog on screen (and in the notification center)

SyntaxScript step badge

Schedule Notification[ Select ; Result ; NotificationID ; Delay ; Title ;
                       Message body ; Action button ; File name ;
                       Script name ; Script parameter; Switches ]

Options

Select entire contentsreplaces 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
NotificationIDa unique id for the notification that you can supply
Delaythe number of seconds to wait before displaying the notification
Titlethe title of the notification
Messagethe 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:

-NoSoundshows the notification without a sound
-ShowNotRequiredthe 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:

$$-50paramErrparameter error
$$-4221invalidOSVersionnotifications are not supported on this OS version
$$-4291notificationsNotEnablednotifications are not enabled in the preferences
$$-4292InitializeErrnotifications could not be initialized
$$-4293scriptWontTrigger(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 17

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”.

Related script stepScript step badge

Remove Notification

Related functionFunction badge

Dial_ScheduleNotification

Related topics

Troi Dialog Plug-in online help (overview)


Online Help Page for Troi Dialog Plug-in for 14 to 17 –> Schedule Notification (dialp7320) 2018-1114 15:13:15