You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a script in ServiceNow to replicate a user's profile. This script not only duplicates the user's data but also replicates the roles and groups assigned to that user.
2
+
3
+
A background script that clones an existing user's profile including all their roles and group memberships to a new user account.
4
+
5
+
## Usage
6
+
7
+
1. Navigate to **System Definition → Scripts - Background**
8
+
2. Copy and paste the script content
9
+
3. Update the function call at the bottom with the source and target user IDs:
10
+
```javascript
11
+
cloneUser('source.username', 'new.username');
12
+
```
13
+
4. Click "Run script"
14
+
15
+
## What It Does
16
+
17
+
The script:
18
+
1. Creates a new user record with the specified username
19
+
2. Copies all field values from the source user to the new user (except fields already set)
20
+
3. Clones all directly assigned roles (excludes inherited roles)
21
+
4. Clones all group memberships
22
+
5. Returns the sys_id of the newly created user
23
+
24
+
## Use Cases
25
+
26
+
- Onboarding new team members with similar access needs
27
+
- Creating test users with specific role/group combinations
28
+
- Setting up backup user accounts with identical permissions
29
+
- Standardizing user setup based on role templates
0 commit comments