Prevent Duplicate User records

Rahul Kathuria
Tera Expert

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

5 REPLIES 5

Inactive_Us1014
Tera Contributor

One easy way of doing this would be to have an insert BR that checks if a user with that name exists already, something along the lines of



(function executeRule(current, previous /*null when async*/) {


        var grUsr = new GlideRecord('sys_user');


        grUsr. addQuery('user_name', current.user_name);


        grUsr.query();


        if (grUsr.hasNext()) {


                  current.setAbortAction(true);


                  gs.addInfoMessage("User with this name already exists");


        }        


})(current, previous);