checking duplicate record

SnowDevOps
Giga Guru

Hello Team,

I'm trying to write a script includes with catalog client script onChange. I have an xyz custom table that has these fields and values:

Full name       HR course                          

John                HR course name A            

 

If John selects HR course Name A, but he already enrolled for this course. The form should alert him and clearValue (some type of onChange and clearValue method). Basically, the form tries to prevent user to have duplicate record on catalog client script. I don't know if you have any sample script that has similar requirement. Please let me know. Thanks for your help 

 

2 REPLIES 2

DrewW
Mega Sage
Mega Sage

There are several ways to do this.

The simplest is to do a GlideRecord query and check to see if the record already exists for Full Name and HR Course and if it does then set the HR course field to a blank value.  Whether or not I use a client side GlideRecord call will depend on how many columns are in the table.  If there are very few I would go with it, but if there are a lot then you may want to use a rest call to the table api so you can limit the amount of data returned.

 

Client side GlideRecord API

https://developer.servicenow.com/dev.do#!/reference/api/utah/client/c_GlideRecordClientSideAPI?navFi...

 

Thanks for the reply. I figured out how to do this one.