How to write email script to print assigned to or assignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2022 10:35 PM
In the email template, I need to print when assigned to available print assigned to (Dear assigned_to). If assigned to not available print assignment group (Dear assignment_group). How to write email script for this condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2022 10:46 PM
Try something like below:
//Assuming notification is on the same table
if(current.assigned_to != "")
template.print("Dear "+ current.assigned_to.name.toString() +",");
else
template.print("Dear "+current.assignment_group.name.toString() +",");
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2022 10:47 PM
You can try below script
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
if(current.assigned_to!=''){
template.print("Hi "+current.assigned_to.first_name+",<br/>");
}else{
template.print("Hi "+current.assignment_group+",<br/>");
}
})(current, template, email, email_action, event);
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2022 11:32 PM
Hello,
You can also write a BR and trigger an event to send the notification. You can pass the value of assigned to or assignment group as property.
Thanks