How to send SLA notification to particular user of current assignment group by workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2023 06:32 AM
Hello,
How to send SLA notification to particular user of current assignment group by workflow create event activity script?
Thank You!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2023 08:35 AM
HI @Shraddha Desai1 ,
I trust you are doing great.
Identify the assignment group and the user you want to send the notification to. Let's assume the assignment group field is assignment_group and the user field is assigned_to.
Create a workflow that triggers on the create event. In the workflow, add an activity script to send the SLA notification.
In the activity script, retrieve the current assignment group and the assigned user for the record. You can use the current object to access the fields.
Get the email address of the user you want to send the notification to. You can use the email field of the user's record.
Compose the SLA notification message. You can customize the message according to your requirements.
Use the ServiceNow email functionality to send the notification to the user. You can utilize the gs.eventQueue object and its enqueueEmail method.
(function execute(inputs, outputs) {
var assignmentGroup = current.assignment_group;
var assignedUser = current.assigned_to;
// Get the email address of the assigned user
var userRecord = new GlideRecord('sys_user');
if (userRecord.get('sys_id', assignedUser)) {
var userEmail = userRecord.email.toString();
// Compose the SLA notification message
var notificationMessage = "Dear " + userRecord.getDisplayValue() + ",\n\n";
notificationMessage += "This is an SLA notification for the assignment group " + assignmentGroup.getDisplayValue() + ".";
// Add more details or customize the message as needed
// Send the notification email
gs.eventQueue.enqueueEmailNotification(assignedUser, null, "SLA Notification", notificationMessage, userEmail);
}
})(inputs, outputs);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi