Interface NotificationMessage
public interface NotificationMessage
Set the subject, message, and text to use in a notification.
Recipient Tokens
Subjects, messages, and text may contain recipient tokens which are automatically replaced for each notification sent to separate recipients.Recipient tokens include:
recipientFirstName
: The recipient's first name.recipientLastName
: The recipient's last name.recipientName
: The recipient's full name, including first and last.recipientMobilePhone
: The recipient's mobile phone number.recipientOfficePhone
: The recipient's office phone number.recipientEmail
: The recipient's email.recipientTitle
: The recipient's title.
Sender Tokens
Subjects, messages, and text may contain sender tokens which are automatically replaced based on the sender set inNotificationParameters
. If the sender is not set, sender tokens will resolve to System values.
Sender tokens include:
senderFirstName
: The sender's first name.senderLastName
: The sender's last name.senderName
: The sender's full name, including first and last.senderUserName
: The sender's user name (login credentials).senderMobilePhone
: The sender's mobile phone number.senderOfficePhone
: The sender's office phone number.senderEmail
: The sender's email.senderTitle
: The sender's title.
Standard Tokens
Subjects, messages, and text may also contain standard tokens, such as${vaultName}
,
${vaultId}
, ${uiBaseExtUrl}
, etc, which are automatically replaced for each notification.
You can view the full list
of tokens in Vault Help.
Note that many standard tokens are specific to some context. For example, ${docName}
,
${Object.name__v}
, and ${taskName}
are specific to a document, object, or workflow,
respectively. Because notifications created on the fly with NotificationMessage
are not associated with a
context, context specific tokens used in these types of notifications will resolve to empty strings.
Custom Tokens
Subjects, messages, and text may contain custom tokens, which must be in the format{$Custom.tokenName}
.
You can set the value of a custom token in setTokenValue(String, String)
.
Persons
If the message recipient is a Person (person__sys
), recipient tokens resolve to System values.
For example, ${recipientFirstName}
will resolve as "System", and ${recipientMobilePhone}
will resolve as an empty String.
To include information about a Person such as Person.first_name_sys
, use RecordService
to retrieve the Person record and Record.getValue(String, ValueType)
to get the
field value. Then you can add this value to your message as a custom token.-
Method Summary
Modifier and TypeMethodDescriptionsetMessage
(String message) Sets the message text for the body of a notification email.setNotificationText
(String notificationText) Sets the text of the in-app notification displayed in the Vault UI.setSubject
(String subject) Sets the subject of a notification email.setTokenValue
(String tokenName, String tokenValue) Sets a custom token value.
-
Method Details
-
setNotificationText
Sets the text of the in-app notification displayed in the Vault UI. If the notification text is not set, an error will occur whenNotificationService.send()
is called with thisNotificationMessage
.- Parameters:
notificationText
- notification text displayed in the Vault UI- Returns:
- the current
NotificationMessage
-
setSubject
Sets the subject of a notification email. If the subject text is not set, an error will occur whenNotificationService.send()
is called with thisNotificationMessage
.- Parameters:
subject
- subject text for the notification email- Returns:
- the current
NotificationMessage
-
setMessage
Sets the message text for the body of a notification email. If the message text is not set, an error will occur whenNotificationService.send()
is called with thisNotificationMessage
.- Parameters:
message
- message text for the body of a notification email- Returns:
- the current
NotificationMessage
-
setTokenValue
Sets a custom token value. Custom tokens must be in the format${Custom.tokenName}
. You can use custom tokens in theNotificationMessage
's text, subject, and message. If a null tokenName or tokenValue is set, an error will occur whenNotificationService.send()
is called with thisNotificationMessage
.- Parameters:
tokenName
- name of a custom token for aNotificationMessage
. This name should not have the Custom prefix, for example, usemyTokenName
rather thanCustom.myTokenName
.tokenValue
- value to set for the custom token- Returns:
- The current
NotificationMessage
-