Need to send notification to assignment group members based on condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2022 06:50 AM
Hello
I have a requirement where i need to send notification to assignment group, But before sending notification i need to validate something and group members who satisfies that validation i need to send only to those members. Is there any way that i can send notification to group members individually based on validation.
Thanks
Akash
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2022 07:36 AM
Hi Akash,
You need to trigger notification by Schedule job by defining condition script for validation go thorough below link for more details.
https://community.servicenow.com/community?id=community_question&sys_id=678959a1db4de7c054250b55ca9619e4
https://community.servicenow.com/community?id=community_article&sys_id=1dd55f001b255010ada243f6fe4bcba8
Kindly mark correct and helpful if its applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2022 09:14 AM
Hi
I am not clear with a few things - 1. When do you want to send the email notification?
2. the logic by which we will decide whether you will send an email or not
I've written a small server-side script that serves your ask. It's tested.
And, you need to create two more things along with the script.
1. create an event from the event registry.
2. create an email notification that will be triggered by the event that you've created in step #1 and mark the event Parm 1 as true so that the correct user will be added to the recipient list.
server-side script:
/*
* assume the table is incident and the incident number is INC0007002.
* First we will get the assignment group and then we will send the email based on the validation
*/
function conditionToSend(userId){
// logic by which we determine whether we will send a notification to the user
// true - yes willl send
// false - no will not
return true/false;
}
var inc = new GlideRecord("incident");
inc.addEncodedQuery("number=INC0007002");
inc.query();
inc.next();
// store the assignment group in a variable assignmentGrp
var assignmentGrp = inc.assignment_group.toString();
// get the list of members
var members = new GlideRecord("sys_user_grmember");
members.addEncodedQuery("group="+assignmentGrp);
members.query();
while(members.next()){
if(conditionToSend){
gs.eventQueue("event_name",members,members.user.toString());
}
}
Regards,
Snehangshu Sarkar
Please mark my answer as correct if it resolves your query.