Notifications

13 views

Description

Customer was able to create multiple records with the same 'User ID'. 

Cause

There is no unique index on sys_user.user_name

Resolution

If the issue is identified in production, it is recommended to take clone of the production to sub-prod and follow the steps in sub-prod first

  1. Identify and remove all the duplicate records from the sys_user table
  2. Check the count on the sys_user table 
  3. Create Unique index on the sys_user table on the user-id field. Below is the procedure
    1. Navigate to System Definition > Tables.
    2. In the list, find the table you want and click its label.
    3. Navigate to the Database Indexes related list.
    4. Click New.
    5. Use the slushbucket to select the fields you want included in the index.
      The order in which you select the fields affects how the index works. If you do not have expertise in database design, you should consult someone who does.
    6. To create a unique index, check the Unique Index box.
    7. Click Create Index
  4. If there are any duplicate records exists, system may not create Unique Index on the table. 
  5. Check the count on the sys_user table. 

 

After creating the unique index, try to create multiple records with the same User Id, following error will occur. 

"Unique Key violation detected by database (Duplicate entry '1234' for key 'user_name')"
"Invalid insert"

 

This means, Unique index creation on User Id is successful. 

Additional Information

https://docs.servicenow.com/bundle/london-platform-administration/page/administer/table-administration/task/t_CreateCustomIndex.html

 

Article Information

Last Updated:2019-11-28 08:05:09
Published:2019-11-28