Please provide the code "Don't allow the member to create duplicate record on custom table"

Srinivasu2
Tera Contributor

Hi Community,

 

I have created a custom table and add 5 fields like From location, To location, journey date, duration, user  and created record

 

Please provide the code for "Don't allow the member to create same kind of record, It will show error message for duplicate record"

 

 

Regards,

Srinivasu

5 REPLIES 5

Amit Verma
Kilo Patron
Kilo Patron

Hi @Srinivasu2 

 

You want to check for duplicity on all the 5 fields or on a single field ? If single, on which field ?

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Hi @Amit Verma.

 

Thank you for the response

 

I want to check for duplicity on the 4 fields, like From location, To location, journey date, user

 

Thanks,

Srinivasu 

Hi @Srinivasu2 

 

Have you tried setting the dictionary field "unique=true" on each of the four fields ? You can give this a try. Also, please refer below links which might be useful :

https://www.servicenow.com/community/developer-forum/duplicate-checking-for-multiple-fields-using-bu...

https://www.servicenow.com/community/developer-blog/search-for-duplicates-delete-based-on-2-columns/...

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

 

Please give this a try and share the results.

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Ankur Bawiskar
Tera Patron
Tera Patron

@Srinivasu2 

you can use before insert BR and query the table to check if combination of those 4 field values exist

what script did you start with and where are you stuck?

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