Add Data or Modify Data if record already exists.

I have a subprocess that loops the returned records from an API call and adds a new record in a data object. I want to modify the process to check if the record already exists and if so, modify the existing record with the data changes.

Like 0

Like

1 comments

First read the record using whatever Identifier you have on it from the source data. If the record exists the Id value will be a Guid and if it doesn't exist the Id of the record will be Guid.Empty.

So the condition for the update will look like: 

[Id from the Read] != Guid.Empty (this means the Read found the record)

The "else" will proceed to the Add, just make sure you populate some identifying value from the API call that you'll use when you read if the record exists next time.

Ryan

Show all comments