Accelerate the Value of Data

Workflow Email Customizations

Learn how to customize email notifications using the Workflow Software Development Kit (SDK).

The Workflow SDK provides an interface for sending email notifications and models of the related object.

Before you can use a custom email notification, switch off the default email notification by setting the NotificationOnAssignmentEnabled and NotificationOnCompletionEnabled parameters to false in the process definition.

Then use the CustomNotificationTaskListener to customize these components oin your email notification:
Notification
Contains notification information.
Attachment
Describes email attachments.
NotificationSenderService.sendNotification(Notification notification)
Sends emails to users with appropriate content.
NotificationSenderService.resolveTaskOwnerEmail(Task task)
Resolves email addresses for a task owner.
NotificationSenderService.resolveTaskAssigneeEmail(Task task)
Resolves email addresses for a task assignee.

Example

This example shows how to use the CustomNotificationTaskListener workflow SDK to send a custom email.

public class CustomNotificationTaskListener implements WorkflowTaskListener {

@WorkflowService
NotificationSenderService notificationSenderService;

public void notify(Task task) {
Notification notification = new Notification();
notification.setTenantId(task.getTenantId());
notification.setSubject("Custom notification on assign");
notification.setBody("This is custom notification on assignment");
notification.addTo(notificationSenderService.resolveTaskOwnerEmail(task));

notificationSenderService.sendNotification(notification);
}
}