Flow Error with DUPLICATE_VALUE for Platform Key fields

MoveData has protections in place to prevent duplicate records being created. These range from key checks to Salesforce Duplicate Checks to unique restrictions on fields. This article explains a unique protection that results in an error email being sent to the Salesforce Administrator.

"I'm getting an 'Error Occurred During Flow' and it says 'DUPLICATE_VALUE'. Why?

In some situations, a platform might dispatch a number of notifications within milliseconds of each other. Regarding Raisely, an example of this might be a "profile.created" followed immediately with a "profile.updated" notification in particular circumstances. This results in a race condition situation. This is where an error occurs that is solely related to two or more transactions executing at the same time.

Continuing with the profile example, we can see there are two transactions that have been received and are being processed at the same time. Notification #1 and #2 have completed lookups for a platform key (ie. 2f978630-7a82-11ed-b55c-d9771a15c1a3) and have fired the organisation's Salesforce Duplicate Rules without a match. The notifications are mapped to new Contact records and created. This will result in two contact records being create - which is no issue due to the next protection.

The post-create rules will fire. Notification #1 will create a platform key for their new Contact record. Fractionally later, notification #2 will also create a platform key for their new Contact. At this point, Salesforce will error as the platform key field requires a unique value and notification #1 has already saved this platform key.

This error will result in notification #2 failing, rolling back all changes (including the duplicated Contact record it created) and Salesforce will send an email noting the error in the flow:

There is nothing that can be done to suppress the failure email being sent. This is unfortunate, as you will see in the next step, MoveData recovers and there is no data alignment issues.

MoveData will be informed of the notification failure. Out-of-the-box, MoveData will attempt to process a transaction three times before marking it as failed. The notification is re-attempted. The first check looks to see if the platform key exists. In the retry, this record does exist. MoveData will load the existing Contact record and continue to execute per the update logic. This ensures the first notification creates the Contact and the second notification updates the Contact with any subsequent changes. The second notification is marked as a success.

Despite all notifications and associated data changes being successfully processed, it isn't unreasonable for a Salesforce Administrator to receive a Flow Failure email with the expectation that there is an error. Unfortunately this email cannot be suppressed but we hope this walkthrough helps in detailing the process and generating confidence there is no issue when DUPLICATE_VALUE errors are received for Platform Key fields.

Last updated