Send dynamic link in email notification to users in watchlist based on their role
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 07:24 PM
We are currently using both the employee center and standard navigation UI. We want to direct users with ITIL role to the standard UI while directing non-ITIL users to the employee center when they click on the link that comes in the email notification.
I am having an issue doing this when there are multiple users in the watchlist with a combination of both ITIL and non-ITIL users.
So far I am able to use email script to go through the watchlist and check whether the user is ITIL or not and then set the URL for the link.
But I am stuck after that because the email ends up just having two links in the same email since the email does not actually get sent until after the email script goes through the watchlist array.
(function runMailScript(current, template, email, email_action, event) {
var link = '';
var watchList = current.watch_list.toString();
var split = watchList.split(",");
var length = split.length;
for (var i=0; i<length; i++){
var usr = gs.getUser().getUserByID(split[i]);
if(usr.hasRole('itil')){
link = gs.getProperty('glide.servlet.uri') + '/nav_to.do?uri=' + current.getTableName() + '.do?sys_id=' + current.sys_id + '"style="color:#ffffff;">';
}
else{
link = gs.getProperty('glide.servlet.uri') + '/esc?id=ticket&table=' + current.getTableName() + '&sys_id=' + current.sys_id +'&view=sp'+ '"style="color:#ffffff;">';
}
template.print('<a href="' + link + "View Ticket" + '</a>');
}
})(current, template, email, email_action, event);
Is there a way to send a different URL to each user in the watchlist based on their role?
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 09:07 PM
Hi, I think the issue is probably that 1 email is sent to the recipients in the watch list and no a subset of users from the watchlist based on role (or lack of).
One solution would be to trigger 2 notifications, one for the roled\instance users, and 1 for the portal users. The basic syntax is the same for your link, but rather than sending the email to your entire watch list you will need to populate your recipients as part of your mail script, based on their role and the notification;
So that all the roled users get the notification with the instance link and all the non roled users get the notification with the portal link.
The other option would be process driven with users added to watch list getting the portal notification and users added to work notes list getting the instance notification.