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:10 AM
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);