Unable to set unique field to true on one of the user table column

VishalC3
Kilo Guru

Hi,

 

I am getting error while trying to make one of the user field (email or employee id) as unique. Objective is to make sure perticular column doesnt accepts duplicate values. 

 

I know this can be done by before business rule too but would like to use OOB approach. 

 

Thanks,

Vishal

5 REPLIES 5

Chanuka
Tera Guru

Hi @VishalC3 

 

You should Check for duplicate records first(emails/employee numbers).Change with the correct data or remove duplicates .Then create unique database indexes for the fields u want to make unique.


If you want to find duplicate emails in the sys_user table quickly.

1.Go to the sys_user table
2.Filter out (email is not empty)
3.Right click the Email column header
4.Select Group By Email.

 

If this helped point you in the right direction, please mark it as Helpful or Accept as Solution!

Ankur Bawiskar
Tera Patron

@VishalC3 

already user_name field is unique on sys_user table at database level

why you want another one?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

HI Ankur,

 

We want to make sure employee id and emails are unique too. This has come up as finding in Health Scan finding.

 

Thanks,

Vishal

yashkamde
Mega Sage

Hello @VishalC3 ,

 

The ootb approach is Unique Table Index.
Creating one is very simple: Open up the Table [sys_db_object] record for your Thing table. Scroll to the bottom to find Database Indexes and click New.

Screenshot 2026-03-12 103852.png

 

This will restrict the duplicate entries :

Screenshot 2026-03-12 103832.png

 

Refer this for more detail :

https://www.servicenow.com/community/developer-articles/how-to-enforce-a-unique-constraint-across-mu... 

 

If my response helped mark as helpful and accept the solution.