- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2018 03:06 PM
i am trying to write a business rule suppose if the user becomes inactive reassign all his incidents to his group manager.
After (Update)
Active changes to false :
(function executeRule(current, previous /*null when async*/) {
var inc =new GlideRecord('incident');
var user = current.sys_id;
inc.addQuery('assigned_to',user);
//inc.addQuery('assignment_group',group);
gs.logs('#000');
inc.query();
while(inc.next()){
var aa = new GlideRecord('sys_user_group');
var man = user.sys_user_group.manager;
aa.addQuery('User',user);
gs.logs('#002');
aa.query();
while(aa.next()){
inc.assigned_to = man;
inc.update();
}
}
})(current, previous);
Please help me out. let me know where i am going wrong or if the whole thing is wrong.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2018 11:48 AM
Try this out:
(function executeRule(current, previous /*null when async*/) {
var user = current.getValue("sys_id"); //should usually use a string version of the data
var inc = new GlideRecord("incident");
//added extra filter so closed/cancelled records are not re-assigned
inc.addEncodedQuery("active=true^assigned_to=" + user);
inc.query();
while(inc.next()){
manager = inc.assignment_group.manager.toString();
if (manager){
inc.assigned_to = manager;
} else {
inc.assigned_to = "";
}
inc.update();
}
})(current, previous);
This will set the "Assigned to" field to the current Assignment group's Manager. If there is no Manager, will simply clear the Assigned to field. You would have to deal with that somehow.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2018 11:25 AM
Hello Nagendra,
Should the Incident be assigned to respective assignment group Manager? If not what should be the behaviour if user is part of multiple groups
-Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2018 12:18 PM
Hello Pradeep,
Yes, the incidents should be assigned to respective assignment group manager.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2018 12:24 PM
Thanks for the update Nagendra. In that case, the script shared by Jim should work.
Thanks,
Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2018 02:09 AM
Hello Pradeep,
i have been going through all the docs for bidirectional integration from SN instance A to B and got nothing from it. if you dont mind can you please help me with this please?