- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 11:05 PM
Hello Everyone,
I am trying to do some scripting in the email notification advance view.
Where I want to achieve that only a ITIL member has able to receive the email when the catalog task is assigned to there group.
e.g the group is combination of IT people and HR. so what i want here is that only IT people can able to receive that notification.
Anyone knows how to achieve this ?
Here is the settings:
When to send:
Send when: record inserted or updated
Condition: assignment group changes or actual start changes and assigned to is empty
Who will receive:
Users/Group in field: assignment_group
Send to event creator: True
I added this code in advance view but non-itil member can still able to receive the email.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 11:14 PM
within email script you can't set the recipients.
Better use after update business rule on your table with proper conditions, event on your table and then trigger the notification via event using eventQueue()
I hope you can do that.
Ensure Event parm1 contains recipient = True in notification
BR script
var recipients = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', current.assignment_group);
gr.addEncodedQuery("user.roles=itil");
gr.query();
while (gr.next()) {
recipients.push(gr.user.toString());
}
gs.eventQueue('event_name', current, recipients.toString());
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 11:14 PM
within email script you can't set the recipients.
Better use after update business rule on your table with proper conditions, event on your table and then trigger the notification via event using eventQueue()
I hope you can do that.
Ensure Event parm1 contains recipient = True in notification
BR script
var recipients = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', current.assignment_group);
gr.addEncodedQuery("user.roles=itil");
gr.query();
while (gr.next()) {
recipients.push(gr.user.toString());
}
gs.eventQueue('event_name', current, recipients.toString());
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 11:55 PM
thank you ankur its work perfectly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 11:27 PM - edited 02-25-2025 11:45 PM
Hello @Jeck Manalo
Please try the below logic
If you found this helpful, please give a thumbs up OR mark it as the solution. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 11:29 PM
are you sure this script will work?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader