
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2020 08:08 AM
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
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2020 02:19 PM
- Create two array variables:
- 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
- Lets call it existingRecordsArray - Array variable to store the unique identifier of existing records in your SN table
- Loop through your "results" variable adding the unique identifiers to the above created array
- 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
- 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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2020 02:09 AM
trying with id and still create new record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2021 07:19 AM
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