- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2016 11:21 AM
Hi Everyone,
I would like to add in a check box on my incident form to notify a Specific Group.
Pseudo Code -
Where: Incident
When: Insert and Update
If "Notify_Management" changes to True, add "Manager" group to the watch list.
Could someone share a script for this based on the info above?
Thank you
Carl
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 10:10 AM
Copy the following script as is in the Business rule. I have tested this and it works. Just replace the highlighted portion with your group name
(function executeRule(current, previous /*null when async*/) {
var members=[];
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group.name','Your group name'); //put your group name here
gr.addQuery('user.active',true);
gr.query();
while(gr.next()){
members.push(gr.getValue('user'));
}
var new_memb='';
if(current.watch_list.toString().length>0)
new_memb=current.watch_list.toString()+','+members.join();
else
new_memb=members.join();
current.watch_list=new ArrayUtil().unique(new_memb.split(',')).join();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 10:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 10:17 AM
glad you got this working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 10:19 AM
I appreciate your help. Now that I am playing with it, I need to figure out a way to UNDO it.
When the check box = FALSE, clear group from the watch list.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 12:00 PM
You could write one more business rule on the incident table
Where: Incident
When: Insert and Update
Conditions: Notify_Management changes to False
Script:
var members=[];
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group.name','Your group name'); //put your group name here
gr.addQuery('user.active',true);
gr.query();
while(gr.next()){
members.push(gr.getValue('user'));
}
var arrayUtil = new ArrayUtil();
var currArr = current.watch_list.toString().split(',');
current.watch_list=arrayUtil.diff(currArr, members).join();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2019 11:28 PM
This post helped me to resolve my requirement, thank you