See: Description
Interface | Description |
---|---|
NotificationMessage |
Set the subject, message, and text to use in a notification.
|
NotificationParameters |
Set the recipients, sender, and other notification options.
|
NotificationService |
Send Vault notifications.
|
NotificationTemplate |
Set the template and tokens to resolve for a notification.
|
This package provides interfaces to send Vault notifications.
person__sys
)A notification has three parts:
You can also set templates for your notifications, which is useful for translating your notifications across multiple languages. Learn more about creating message templates 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 with the SDK are not associated with a context, these tokens will resolve as empty Strings.
You can also create custom tokens, which must be in the format {$Custom.tokenName}. You can set the value of a custom
token in NotificationMessage.setTokenValue(java.lang.String, java.lang.String)
and NotificationTemplate.setTokenValue(java.lang.String, java.lang.String)
.
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(java.lang.String, com.veeva.vault.sdk.api.core.ValueType)
to get the field value. Then you can add this value to your NotificationMessage or NotificationTemplate as a custom token.
Learn more about tokens in NotificationMessage
.
//Get your recipient userIds, Groups, and RecordRoles
Set<String> recipients = VaultCollections.newSet();
recipients.add(currentUserId);
GroupService groupService = ServiceLocator.locate(GroupService.class);
List groupNames = VaultCollections.newList();
groupNames.add("sdk_group__c");
GetGroupsResponse groupResponse = groupService.getGroupsByNames(groupNames);
Group group = groupResponse.getGroupByName("sdk_group__c");
List groups = VaultCollections.newList();
groups.add(group);
RecordService recordService = ServiceLocator.locate(RecordService.class);
Record record = recordService.newRecordWithId("study__v", studyId);
List records = VaultCollections.newList();
records.add(record);
RecordRoleService recordRoleService = ServiceLocator.locate(RecordRoleService.class);
GetRecordRolesResponse recordRoleResponse = recordRoleService.getRecordRoles(records);
RecordRole recordRole = recordRoleResponse.getRecordRole(record, "viewer__v");
List recordRoles = VaultCollections.newList();
recordRoles.add(recordRole);
//NotificationService
NotificationService notificationService = ServiceLocator.locate(NotificationService.class);
//NotificationParameters
NotificationParameters notificationParameters = notificationService.newNotificationParameters();
notificationParameters.setRecipientsByUserIds(recipients);
notificationParameters.setRecipientsByGroups(groups);
notificationParameters.setRecipientsByRecordRoles(recordRoles);
notificationParameters.setSenderId(senderId);
//NotificationTemplate
NotificationTemplate template = notificationService.newNotificationTemplate()
.setTemplateName("product_change_notification_template__c")
.setTokenValue("productName", productName);
//Send Notification with a NotificationTemplate
notificationService.send(notificationParameters, template);
product_change_notification_template__c
is the name of a
template created by an Admin in Vault. Below is an example of what this template may look like:
Hello ${recipientName}, The product ${Custom.productName} profile has been modified. Please review the changes. Regards, ${senderName}
Copyright © Veeva Systems 2017–2019. All rights reserved.