Skip to content

Commit 414b638

Browse files
committed
Update README to guide how to add department-role mappings
1 parent 85b5263 commit 414b638

File tree

1 file changed

+15
-6
lines changed
  • Background Scripts/Automate Role Assignment for New User

1 file changed

+15
-6
lines changed
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
This snippet assigns specific roles to users based on their department within ServiceNow.
1+
# Overview
2+
This snippet for ServiceNow developers automate the process of assigning roles to users based on their department. It helps to simplify user role management, especially useful in organizations where specific departments require predefined access levels.
23

3-
Departments are matched against a predefined dictionary, and roles are applied accordingly. To modify, update the `rolesByDepartment` dictionary with your organization’s department-role mappings.
4+
5+
# How It Works
6+
The script:
7+
- **Identifies the User's Department**: Retrieves the department name of the current user, which is then used as a key to look up relevant roles.
8+
- **Defines Role Mappings**: Uses a dictionary `rolesByDepartment` to map departments (like IT, HR, and Finance) to arrays of role names.
9+
- **Assigns or Removes Roles**:
10+
- Clears Existing Roles: Empties the user’s current role list to avoid duplicate or outdated assignments.
11+
- Adds New Roles: Based on the department lookup, the script assigns the appropriate roles from the predefined list.
12+
13+
# Implementation
14+
15+
Update `rolesByDepartment` to reflect your organization’s specific department-role mappings.
416
```
517
var rolesByDepartment = {
618
<department_name> : [role_1, role_2]
719
};
8-
```
9-
10-
11-
This script ensures automatic and consistent role assignment, streamlining access control for large teams.
20+
```

0 commit comments

Comments
 (0)