How do I send notifications when a user is added to a case?
If you want to send a notification when a user is added to a case, you can use this sample code.
try {
println("Preparing data to send notification.");
def map = new HashMap();
// Specify default MessageText
def messageText = "You are included in the team for Case: " + CaseNumber;
// Specifying the recipient
def recipientPartyId = PartyId;
// Resolving Parent child object relation
def objectCode='CaseVO';
Long objectId = CaseId;
// Specify one or more channels
map.put("Channels",["ORA_SVC_BELL"]);
map.put("MessageText", messageText);
// The following can be used to pass a Long PartyId
map.put("RecipientPartyId", recipientPartyId);
map.put("ObjectCode", objectCode);
map.put("ObjectId", objectId);
if (recipientPartyId) {
// Call to send notification
println("Sending notification...");
adf.util.sendNotification(adf, map);
println("Notification sent to user id: " + recipientPartyId);
} else {
println("No recipient. Notification will not be sent.");
}
} catch (e) {
// Log the failure in groovy logging. Logs can be viewed in 'RuntimeMessages'.
println("Failure to trigger notification from Groovy Script " + e.getMessage());
}