The CreatorCon Call for Content is officially open! Get started here.

Scripted REST API creating duplicate records

Anirudh Gupta
Kilo Expert

Hello everyone, Hope you are doing good!

Here came a situation where we have a scripted rest api wherein a third party system creates records in the ServiceNow instance. But the third party system sends the data rapidly and the scripted rest api isn't able to work synchronously with it. In this case if the third party system sends duplicate records those gets created in SNOW.

We have an initial check in place i.e. if a matching record is found just return the sys_id of the record to the tp system, but by the time script checks it there is another record created with a different sys_id but the exact same data (duplicate).

Any suggestions on this that should be incorporated ?

3 REPLIES 3

Santosh_Ksagar
Mega Sage

Hi Anirudh,

Could you explain more on how you check for duplicate records in your system? and why it is still creating a duplicate record? 

Thanks
Santosh

Luuk E
Tera Contributor

Hi anirudh,

i suggest looping over the returned records and doing an extra check on the value that you know is going to be the same for example name,number etc. before inserting the record in ServiceNow. 

Something like below will probably do the job.

find_real_file.png

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

Put this data in one staging table and then do the transform of the data synchronously there. In onbefore transform script you can check the duplicates.

Thanks,
Ashutosh