How to send SLA notification to particular user of current assignment group by workflow?

Shraddha Desai1
Tera Contributor

Hello,

 

How to send SLA notification to particular user of current assignment group by workflow create event activity script?

 

Thank You!

1 REPLY 1

Amit Gujarathi
Giga Sage
Giga Sage

HI @Shraddha Desai1 ,
I trust you are doing great.

  1. 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.

  2. Create a workflow that triggers on the create event. In the workflow, add an activity script to send the SLA notification.

  3. 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.

  4. 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.

  5. Compose the SLA notification message. You can customize the message according to your requirements.

  6. 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