function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mayara miranda 5mayara miranda 5 

ERROR duplicate value found

hello, I have a problem, the external system sends data to my salesforce org where it creates the surveys.

but i am getting these duplicate data errors, how can i fix this? I cannot capture the error log, I need to identify what is causing this error, as the data comes from an external system.


duplicate value found: NumberofControle__c duplicates the value in the register with ID: aaQ2A0000160wOk, Chassis__c duplicates the value in the register with ID: aaQ2A0000160wOk
AbhinavAbhinav (Salesforce Developers) 
Hi Mayara,

The scenario might be as follows: 
Since multiple requests being sent, there might be an overlapping request. That is, if the same record has been sent simultaneously/with milliseconds of gap, it might be possible that the first records is under process while the second record is again taken up for processing. Then the server finds the second record as a duplicate and throws the error.

Resolution
The best possible solution for this scenario would be to synchronize the requests.
Make sure, only one record is present in a request/in a batch of requests.
While there is no time gap set by Salesforce as such between consecutive requests, it would be a good practice to program the requests in a way to have some milliseconds of time gap between two requests (if the same record is being sent multiple requests)

Reference:
https://help.salesforce.com/articleView?id=000318436&language=en_US&mode=1&type=1

Thanks!