Interface NotificationTemplate
NotificationService.newNotificationTemplate() and sent using
NotificationService.send(NotificationParameters, NotificationTemplate).
Templates support custom tokens, which can be populated using either setTokenValue(String, String) for simple
cases or setTokenResolver(Consumer) for advanced, dynamic resolution based on language.
Learn more about tokens in com.veeva.vault.sdk.api.notification.
-
Method Summary
Modifier and TypeMethodDescriptionsetTemplateName(String templateName) Sets the name of the notification template to use.default NotificationTemplatesetTokenResolver(Consumer<TokenResolverInput> tokenResolverInputConsumer) Sets aConsumerto dynamically resolve token values at send time, which is useful for complex, multi-language scenarios.setTokenValue(String tokenName, String tokenValue) Sets the value for a custom token defined in the template.
-
Method Details
-
setTemplateName
Sets the name of the notification template to use. This is a required field.If the template name is not set or is invalid, an error will occur when
NotificationService.send(NotificationParameters, NotificationTemplate)is called.- Parameters:
templateName- The public key (e.g.,my_template__c) of the notification template.- Returns:
- The current
NotificationTemplateinstance for method chaining.
-
setTokenValue
Sets the value for a custom token defined in the template. Custom tokens are referenced in the template as${Custom.tokenName}.Custom token names can only contain alphanumeric characters and underscores [a-z, A-Z, 0-9, _] and must be 40 characters or less.
If the token name or value is null, an error will occur when
NotificationService.send(com.veeva.vault.sdk.api.notification.NotificationParameters, com.veeva.vault.sdk.api.notification.NotificationMessage)is called.- Parameters:
tokenName- The name of the custom token (e.g.,myTokenName, notCustom.myTokenName).tokenValue- The value to substitute for the token.- Returns:
- The current
NotificationTemplateinstance for method chaining.
-
setTokenResolver
default NotificationTemplate setTokenResolver(Consumer<TokenResolverInput> tokenResolverInputConsumer) Sets aConsumerto dynamically resolve token values at send time, which is useful for complex, multi-language scenarios. The consumer receives aTokenResolverInputcontaining the required tokens and languages, and it must provide the resolved values via theTokenResolverOutput.The default implementation does not set a Consumer for resolving tokens.
- Parameters:
tokenResolverInputConsumer- AConsumerthat implements the logic to resolve token values.- Returns:
- The current
NotificationTemplateinstance for method chaining.
-