- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2025 06:13 AM
Hi everyone,
Based on a new incident record, both the Caller and the Opened by users should receive a notification. However, if either of them belongs to the Help Desk group, that user should not receive the notification.
Example:
If the Caller is part of the Help Desk group and Opened by is not, only the Opened by user should receive the notification — and vice versa.
How can we implement this logic?
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2025 07:27 AM - edited 04-17-2025 07:29 AM
Hello @Paulo Machado
Below are the steps:
1. Create a system property for Help Desk Group sys_id (Table: sys_properties.LIST) --> Best practice to not hard code sys_id and have roles associated with the sys property
2. Create an Event (Table: sysevent_register)
3. Create email notification (Table: sysevent_email_action)
4. Create an insert Business Rule on Incident Table:
(function executeRule(current, previous /*null when async*/) {
var helpDeskGroupId = gs.getProperty('helpdesk.group.sysid');
function validateUserHelpDeskMembership(userId) {
var grUsr = new GlideRecord('sys_user_grmember');
grUsr.addQuery('user', userId);
grUsr.addQuery('group', helpDeskGroupId);
grUsr.query();
return grUsr.hasNext();
}
if (!current.caller_id || !current.opened_by) {
return;
}
var callerValidation = validateUserHelpDeskMembership(current.caller_id);
var openedByValidation = validateUserHelpDeskMembership(current.opened_by);
if (callerValidation && openedByValidation) {
gs.log('VJ1: Email will be sent to Opened By: ' + current.opened_by.email);
gs.eventQueue('incident.custom_notify', current, current.opened_by.email, '');
}
})(current, previous);
Validation Results:
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2025 06:27 AM
I think with just one notification, it's not possible. You need to create two notifications, each with different conditions. Now, the question is how to check if a user is part of a group or not, which you'll need to verify.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2025 06:48 AM
Only 1 notification required
you can use after insert business rule and trigger the event from that business rule and determine the recipient dynamically based on group membership
Link that event with notification
I hope you can configure notification, event and the content using docs
After Insert BR:
(function executeRule(current, previous /*null when async*/) {
// Get the Caller and Opened by users
var caller = current.caller_id;
var openedBy = current.opened_by;
// Function to check if a user is in the Help Desk group
function isInHelpDeskGroup(user) {
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', user);
gr.addQuery('group.name', 'Help Desk');
gr.query();
return gr.hasNext();
}
// Check if the Caller is in the Help Desk group
var callerInHelpDesk = isInHelpDeskGroup(caller);
// Check if the Opened by user is in the Help Desk group
var openedByInHelpDesk = isInHelpDeskGroup(openedBy);
// Send notifications based on the group membership
if (!callerInHelpDesk) {
gs.eventQueue('incident.notify.caller', current, caller, null);
}
if (!openedByInHelpDesk) {
gs.eventQueue('incident.notify.opened_by', current, openedBy, null);
}
})(current, previous);
In Email Notification "Event parm1 contains Recipient" Should be true
Event: on incident table
Notification: on incident table
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
04-17-2025 08:46 PM
Thank you for marking my response as helpful.
I believe I have also answered your query.
As per new community feature you can mark multiple responses as correct.
If my response helped please mark it correct as well 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
04-17-2025 07:27 AM - edited 04-17-2025 07:29 AM
Hello @Paulo Machado
Below are the steps:
1. Create a system property for Help Desk Group sys_id (Table: sys_properties.LIST) --> Best practice to not hard code sys_id and have roles associated with the sys property
2. Create an Event (Table: sysevent_register)
3. Create email notification (Table: sysevent_email_action)
4. Create an insert Business Rule on Incident Table:
(function executeRule(current, previous /*null when async*/) {
var helpDeskGroupId = gs.getProperty('helpdesk.group.sysid');
function validateUserHelpDeskMembership(userId) {
var grUsr = new GlideRecord('sys_user_grmember');
grUsr.addQuery('user', userId);
grUsr.addQuery('group', helpDeskGroupId);
grUsr.query();
return grUsr.hasNext();
}
if (!current.caller_id || !current.opened_by) {
return;
}
var callerValidation = validateUserHelpDeskMembership(current.caller_id);
var openedByValidation = validateUserHelpDeskMembership(current.opened_by);
if (callerValidation && openedByValidation) {
gs.log('VJ1: Email will be sent to Opened By: ' + current.opened_by.email);
gs.eventQueue('incident.custom_notify', current, current.opened_by.email, '');
}
})(current, previous);
Validation Results:
Hope that helps!