Merge Duplicate User Records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2019 01:55 PM
I have 300 duplicate user records i need to merge. I already fixed the issue creating the dups but now i need to do cleanup. I created a list view of the duplicates where i can also view the sys_ID of each user record. But I need to link any of the old user records - associated tasks or incidents to the new user record. I googled this all day and cannot find a good lead on a way to accomplish this. Again I identified the duplicate records. I identified their sys_ids, but now I need to find a way to point any related tickets to the new user record and make the the old user record inactive.
- 3,565 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2019 02:35 PM
create a filter first.
1.
To list out the Incidents and Tasks which assigned to old user profiles import those all those records .
2.u can delete the old profiles in the step
3.
Download to excel sheet and check the incidents and Tasks assigned to it . After downloading the records delete the old profile list in excel sheet also and update the new profile and export the records into service-now it will work let me know if you any doubts to implement this

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2019 02:35 PM
Below script queries all the task extended tables and update the assigned to value with new user info
var old_users = ['user1_old_sys_id', 'user2_old_sys_id'];
var new_users = ['user1_new_sys_id', 'user2_new_sys_id'];
for(i=0; i<old_users.length; i++){
var gr = new GlideRecord("task");
gr.addQuery("assigned_to", old_users[i]);
gr.query();
while (gr.next()) {
gr.assigned_to = new_users[i];
gr.update();
}
}
/ To inactivate Users
var usr = new GlideRecord("sys_user");
usr.addQuery("sys_id", old_users);
usr.query();
while (usr.next()) {
usr.active = false;
usr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2019 02:43 PM
I option would be to create a field in user table, which will store the the new user's record.
Then query all the user records with while loop which has a New user record associated, and then
- query the task table with opened By = that record. if matches, updated it.
- query the task table with Assigned= that record. if matches, updated it.
- query the sc_request table where Requested For = old record
- query incident table where caller = old record
and so on.
Please mark this response as correct or helpful if it assisted you with your question.