- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hey everyone
We need to create a group that automatically includes users from specific departments (from departments table or department field in sys_user). We share the tenant with another part of the organization and we want a role that applies only to our employees. What is the best way to set this up so members are added and removed automatically?
Solved! Go to Solution.
- Labels:
-
Users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Found a solution for this. I created a scheduled job that runs daily to add all users from the specified departments to the group, and another job that removes inactive users or those who have moved out of the department.
Using a consistent prefix for all departments under the same organizational unit makes this much easier to manage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @MujeebQ
This solution might help you
https://www.servicenow.com/community/developer-forum/can-you-create-a-dynamic-group/td-p/1808324
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Found a solution for this. I created a scheduled job that runs daily to add all users from the specified departments to the group, and another job that removes inactive users or those who have moved out of the department.
Using a consistent prefix for all departments under the same organizational unit makes this much easier to manage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @MujeebQ ,
Best approach: use a Dynamic Group with a scripted membership condition.
Steps:
Go to User Administration → Groups → New → Dynamic Group.
In the Dynamic Group Script, add logic like:
// Include users from specific departments (function() { var depts = ['IT', 'Finance']; // replace with your department names var userDept = current.department.getDisplayValue(); return depts.indexOf(userDept) > -1; })();Save and assign the required role(s) to this group.
The platform will automatically add/remove members as users’ department fields change — no manual sync needed.
✅ Why this way:
Avoids cloning user records or manual maintenance.
Keeps role assignment scoped to your org segment.
Automatically stays updated as departments or users change.
