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
sijumv2sijumv2 

|System.DmlException: Upsert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found:

 Hi All,

I am getting an exception 

USER_DEBUG [6]|DEBUG|System.DmlException: Upsert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: []

when I am trying to insert an EntitySubscription  record

EntitySubscription en=new EntitySubscription(NetworkId = commId, SubscriberId = sid, ParentId = pid);
try{upsert en;}catch(Exception e){System.debug(e);}

I checked for duplicate records but there are no duplicate i could find in workbench

Thanks
Best Answer chosen by sijumv2
TintuBabuTintuBabu
Hi
Please check this.
http://danielsokolowski.blogspot.in/2014/08/duplicate-value-found-duplicates-value.html
https://sfdcdev.wordpress.com/2011/07/08/upsert-failed-first-exception-on-row-0-first-error-duplicate_value/

All Answers

TintuBabuTintuBabu
Hi
Please check this.
http://danielsokolowski.blogspot.in/2014/08/duplicate-value-found-duplicates-value.html
https://sfdcdev.wordpress.com/2011/07/08/upsert-failed-first-exception-on-row-0-first-error-duplicate_value/
This was selected as the best answer
sijumv2sijumv2
Sorry Tintu, tried that its not working. Thanks
Daniel HowellDaniel Howell
Try and specify the field to upsert on 
Instead of 
upsert en;
Try
upsert en custom_field__c;