- 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-01-2016 11:50 AM
What is a manager group? Is there a field that has manager group?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2016 11:59 AM
something like this should work
var members=[];
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group','your group goes here');
gr.addQuery('user.active',true);
gr.query();
while(gr.next());
members.push(gr.getValue('sys_id'));
}
var new_memb=current.watch_list.toString()+','+members.join();
current.watchlist=new_memb;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 06:43 AM
Hi Abhinay,
Thank you for your reply. I tried the example you provided below and got an error on line 10
It says expected ')' to match '(' from line 1 and instead saw 'var'
I've tried a few things but not able to clear that error.
If you get a chance can you take a look and see where I went wrong?
Appreciate it and glad to see you again!
Carl

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 07:58 AM
Need to make sure you close out the parenthesis that were opened in line 1. Just make sure you have the closing bracket and parenthesis at the bottom of the script.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
})(current, previous); // Make sure this is at the bottom of the script!