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

Avoid duplicate records

Serhii5
Mega Guru

Hi guys, how is it possible to check before insert if the same record exists? I have script include which fetching data and I would like to modify it to validate if a record exists - update it with new data if no -insert new 

 

find_real_file.png

1 ACCEPTED SOLUTION

  1. Create two array variables:
    1. Lets call it resultsArray - Array variable to store the unique identifier that you can use to query your SN table for existence of a record
    2. Lets call it existingRecordsArray - Array variable to store the unique identifier of existing records in your SN table
  2. Loop through your "results" variable adding the unique identifiers to the above created array
  3. Query your SN table using the "resultsArray" list to find records that match that identifier.  Loop through the found records and populate the "existingRecordsArray" with the unique identifier
  4. Loop through your "results" variable again but check your "existingRecordsArray" to decide to skip or update versus insert

 

I hope this make sense.  Doing it this way will process records much more efficiently since you aren't doing 10000 GlideRecord queries.

View solution in original post

11 REPLIES 11

trying with id and still create new record

Hi Serhii,

Can you pls share your updated script, I have also same kind of requirement and if you could share the updated script that would help me. thanks in advance.

Thanks,

Suresh Selvam