Capturing activity error into mail notification

In the Process Designer, right click on the activity and attach the error intermediate event.

- Now double click the activity on which you have attached error intermediate event.(Attach the Error intermediate event to end event).
- In the bottom panel of Process designer , Click the OnException Scripts > Edit Service Exception.
- Add the attached script in the window open and save it.
- Now right click on the same activity and select ServiceException Dialog and add the same script in the window opened and save it.
- Attached the mail notification activity to the End Event by double clicking on it and selecting the required activity from bottom panel.
- Now to add user define message along with error message you have to use Put context variable. Attach this put context variable before schema.
- Now when you edit this put context variable, Write "endNotificationUserMessage" in variable name field and your message in variable value.

Note that you have to write the mail notification name in quotes in the script attached :

String mailNotificationActivityName = "";


import java.util.*;

String mailNotificationActivityName = "";
String activityParamsName = mailNotificationActivityName + ".params";
Map params = context.get(activityParamsName);
if(params == null){
params = new HashMap();
String endNotificationUserMessage = context.get("endNotificationUserMessage");
String midSeparator = " ";
if(endNotificationUserMessage == null){
endNotificationUserMessage = "";
midSeparator = "";
String endNotificationErrorMessage = context.get("endNotificationErrorMessage");
String separator = ",";
if(endNotificationErrorMessage == null){
endNotificationErrorMessage = "Error Message :: ";
separator = "";
String errorMessage = "Exception occured, but no error message found";
if(exception != null){
errorMessage = exception.getMessage();
endNotificationErrorMessage += separator + errorMessage;
context.put("endNotificationErrorMessage", endNotificationErrorMessage);
String endNotificationMessage = endNotificationUserMessage + midSeparator + endNotificationErrorMessage;
params.put("message", endNotificationMessage);
context.put(activityParamsName, params);

Have more questions? Submit a request


Article is closed for comments.