How to Send Notification Based on Role or ACL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 12:45 PM
We have had a business case come up where users in the 'caller' field that have the 'itil' role need to receive our email notification when anything is added to the worknotes even if they are not @mentioned. My thought was I could dot walk a condition where caller>roles>contains>itil but that doesn't seem to be available. Adding an ACL to the notification also did not seem to be an option.
I do not have scripting background so I am unsure how the script would be written so that if I were to add 'caller' to the users/groups that receive the email the script will check to make sure that the 'caller' in the field has the 'itil' role.
Can someone please assist?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 01:11 PM
Is this notification's "When to send" a table condition or when an event is triggered?
- If table condition, I suggest changing to event is triggered.
- For event is triggered, you're looking at creating a business rule (you can use the condition on the business rule to only trigger when it needs to send the notification. It will be an advanced business rule and in the script you will so something like this (note, the event is just made up here, if you aren't already using an event, then you should create an event under event registry).
var user = gs.getUserByID(current.getValue('caller'));
var hasItil = user.hasRole('itil');
if(hasItil){
gs.eventQueue("incident.new_work_note", current, user.getID(), user.getName());
} else{
gs.eventQueue('incident.new_work_note', current, '', '');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 01:31 PM
I noticed Kristen posted a similar solution while I was typing this. I'm posting it anyways, the difference is that mine involves adding a new notification rather than changing the existing "Incident worknoted for ITIL" notification.
This probably isn't an elegant solution, but I'm thinking you could copy the email notification and make some changes. This new copied email notification would be modified as such:
Send when: event is fired. We would need a new event, called say incident.worknoted.
Who will receive: Users/Groups in fields -> Caller
Create the incident.worknoted event.
And finally create a new business rule, same condition as the email notification: incident table, work notes changed. It would be advanced and have a script similar to below:
var user = gs.getUserByID(current.getValue('caller'));
var hasItil = user.hasRole('itil');
if(user.hasRole('itil'))
{
gs.eventQueue('incident.worknoted', current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2024 05:59 AM
Hello,
You can accomplish this with a simple Business rule.
Since there is a an out of box email notification 'Incident worknoted for ITIL' and the recipients are 'Assigned to' and 'Work notes list', I would add the caller to the 'work notes list' if the caller has 'itil' role.
Script :
Trigger On Insert and 'Caller' is not empty
Script:
//Get caller
var user = gs.getUserByID(current.getValue('caller'));
//Cehck if caller has 'itil' role
var hasItil = user.hasRole('itil');
if(hasItil){
//Add caller to the work notes list if current work notes list is empty
if(current.work_notes_list.nil())
current.work_notes_list = current.caller.sys_id;
else
//APPEND caller to the work notes list if current caller list is not empty
current.work_notes_list += ','+'current.caller.sys_id;
}
Hope you find this helpful!
Thanks!
Raj