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
Maros SitkoMaros Sitko 

insert vote object

Hi, I have issue with inserting vote object. My code in controller is

Vote newVote = new Vote(ParentId = articleId, Type = myvote);
try{
insert newVote;
} catch(DmlException e) {
ApexPages.addmessage(new ApexPages.Message(ApexPages.Severity.WARNING, e.getMessage()));
}

 

 

and I get error

Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: []
 

 

 

Any suggestion? Thank you

sfdcfoxsfdcfox
It would appear you've already voted on that record. That's what DUPLICATE_VALUE means.