- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 05:54 AM
Hi All,
i have a requirement that whenever a user is marked inactive in sys_user table,
1. we need to check open incidents, tasks, problems and assign them to the group itself(make assigned to blank)
2.For any applications/CI where user is a owner/tech lead - generate a list and trigger notification
3.Remove the user from the group
I tried to create a scheduled job to remove members from group and created a BR on sys_user_grmember to reassign the open tasks to group.however i see that it is also removing assigned to for Resolved tickets as well and unable to achieve point 2.
below is my script
(function executeRule(current, previous /*null when async*/) {
var groupId = current.getValue("group");
var groupName = current.group.getDisplayValue();
var userId = current.getValue("user");
var userName = current.user.getDisplayValue();
//look for all Active Task records assigned to the Group AND User
var grpm = new GlideRecord("task");
grpm.addEncodedQuery("active=true^assignment_group=" + groupId + "^assigned_to=" + userId);
grpm.query();
while (grpm.next()) {
//add a work note to let people know why the field was cleared
grpm.work_notes.setJournalEntry("Assigned to field cleared because '" + userName + "' was removed from the current Assignment group '" + groupName + "'");
grpm.assigned_to = "";
grpm.update();
}
})(current, previous);
Can someone please help on how i can achieve this with a BR on sys_user table itself on when active changes to false? any help on this will be greatly appreciated
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2022 11:16 PM
Please mark Correct and Helpful if my answer helps you resolve your issue.
Тhis will close the thread and other users may also benefit from it.
Thanks!
Martin Ivanov
Community Rising Star 2022
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2022 11:16 PM
Please mark Correct and Helpful if my answer helps you resolve your issue.
Тhis will close the thread and other users may also benefit from it.
Thanks!
Martin Ivanov
Community Rising Star 2022
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2022 04:07 AM
Hi, I am struggling to get this business rule to work. I am trying to achieve the same Atheher's point 1. 'check open incidents, tasks, problems and assign them to the group itself(make assigned to blank)'
I have tried creating a business rule and included the script with amended encoded query, but am a little confused by the post above as to which table this business rue should run on. Should it run on sys_user_grmember table or on sys_user table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2022 04:42 AM
I eventualy created a time based flow to achieve this and it is working like a charm.please try using flow desginer. you can either trigger it on a specific time or when the record in sys_user table gets updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2022 06:11 AM
Hi,
thanks for your response. Would you be able to share the updated script please? If I set this up as a business rule to trigger when user = active changes to 'false' , which table should the rule run on?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 07:23 AM
Were you able to solve the issue for this? I also have the same requirement. If you can provide the code, that would be really helpful.
1. we need to check open tickets and assign them to the group itself(make assigned to blank)