Prevent Duplicate User records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2016 09:00 AM
Hi,
We have so many duplicate user records in ServiceNow. Clean Up process is in Progress. I want to implement a rule which will restrict the admins/interface to create duplicates based on User ID field. Let's say i have a userid "rkathuria" already in the user table, if i try to create a new user id with this name then i should get a pop up or an error message saying " User account with this name already exists in the system" and further action should be aborted.
Any help on this would be appreciated.
Thanks,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2016 09:05 AM
Rahul,
This feature you're looking for is already out of the box if a admin or user who has rights to create a new user account via user form. If you take any user id and create one user record and try to create a second one with the same user id the system will abort insert and display below message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2016 09:19 AM
Patrick - i am in Eureka..i guess it will be out of the box in later releases if that is the case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2016 09:28 AM
It works in eureka. Did you try it?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2016 09:07 AM
Hi Rahul,
Modify as per your requirement. Business Rule (before update,insert)
// Here I have checked for both insert and update to avoid duplicates
function onBefore(current, previous) {
if (current.operation() == "update") {
checkDuplicateUpdate();
} else {
checkDuplicateInsert();
}
}
function checkDuplicateInsert()
{
var dup = new GlideRecord("tablename");
dup.addQuery("u_language", current.u_language);// user field
dup.addQuery("u_active", 'true');
dup.query();
if (dup.next()) {
gs.addInfoMessage('Already record exists in the table with same language.Check the existing routing ID ' +dup.u_l1_helpdesk_routing_id);
current.setAbortAction(true);
}
}
function checkDuplicateUpdate()
{
var dup = new GlideRecord("Tablename");
dup.addQuery("u_language", current.u_language);// userfield
dup.addQuery("u_active", 'true');
dup.query();
if (dup.next()) {
//gs.addInfoMessage('count' +dup.getRowCount());
gs.addInfoMessage('Already record exists in the table with same language .Check the existing routing ID '+dup.u_l1_helpdesk_routing_id);
current.setAbortAction(true);
}
}
Harish