Duplicate user's associate tasks to merge
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi All,
We have observed that there are duplicate user records (sometimes more than three) with the same name in the system. However, only one of these users has a valid User ID, while the others do not.
When opening a user's profile, we can see related records under the related lists — such as Incidents, RITMs, and Requests. To address this, we are currently using a background script to migrate all task-related records from the duplicate (invalid) user profiles to the valid user (with the correct User ID).
Now, the client has requested to perform this de-duplication process via a Record Producer. I have created two reference variables:
Primary Username – the user to retain (valid user with User ID)
Secondary Username – the duplicate user to merge (missing User ID)
Kindly provide a Client Script and Script Include to implement this functionality through the Record Producer.
var primarySysId = '021bc84247598a105419f422516d43e3';
var secondarySysId = '8be12086c3dd02d093fa12deb0013145'; var grTask = new GlideRecord('task');
grTask.addEncodedQuery('u_requester=' + secondarySysId);
grTask.query();
while (grTask.next()) { var table = grTask.sys_class_name.toString(); var gr = new GlideRecord(table);
gr.addQuery('number', grTask.number);
gr.query();
if (gr.next()) {
if (table == 'sc_req_item') {
gr.u_requester = primarySysId;
} if (table == 'sc_task') {
gr.u_requester = primarySysId;
}
if (table == 'incident') {
gr.caller_id = primarySysId;
}
if (table == 'sc_request') {
gr.requested_for = primarySysId;
}
gr.setWorkFlow(false);
gr.autoSysFields(false);
gr.update();
}
}
- Labels:
-
Cost Management (ITSM)