Email notification - Check recipients role on all emails sent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2017 12:06 PM
Hi SNOW Dev Community,
Question around email notifications that get sent referencing a records number. So what I am doing is whenever an email is getting sent out that includes my notification script the script is checking the users role and spitting out a template print based on if the user has the itil role or not. I am only using this when I go to reference a records number.
Scenario -
Incident notification goes out with incident details. The details include the incident number. I want the number be just the number if the user does not have an ITIL role and a URI_REF if the user does have an ITIL role.
<tr><th>Incident #:</th>
<td>${mail_script:incident.link.role.check}</td>
</tr>
<tr><th>Opened At:</th>
<td>${opened_at}</td>
</tr>
<tr><th>Opened By:</th>
<td>${opened_by}</td>
</tr>
Notification Script -
attachLink();
function attachLink() {
//Check for requestor's role
var userObj = gs.getUser().getUserByID(current.caller_id);
if (userObj.hasRole('itil')) {
template.print('${URI_REF}');
}
else {
template.print('${number}');
}
}
Instead of making it so that the script checks for a specific field, in this case the caller_id, can I make it so that it just checks whomever the email is getting sent to? I only need this check to happen when my notification includes a ${number} or ${URI} reference.
Thoughts?
Thanks in advance,
Sean
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2019 11:16 AM
This post has a good recommendation: https://community.servicenow.com/community?id=community_question&sys_id=7e8c4fa5db9cdbc01dcaf3231f96...