Hi,
I have an Apex Class which is called via a REST Api Apex class.
One of the things it does is to update `Account` records (selected with a SOQL query in the failing method), and just sets a Checkbox field to `false`.
If I call the class directly (through AnonApex) it works as expected.
But, if it's called via the REST Api class it fails with this error:
DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>
- The same Account records are used in both tests.
- The Account object has no Unique fields
- I've tried disabling any Triggers and Flows on the Account record, and it still fails.
- It works OK in Production - this happens in the Sandbox. To try and resolve this, we refreshed the (partial) Sandbox - but the error still happens.
- The method that fails has no parameters - it's called in exactly the same way in both tests
- I'm using the same User (a Sys Admin) for both tests.
- I've tried using `update acc` and `Database.update(acc, true & false)` (true & false being the AllAorNothing flag) and all three fail in the same way
I've run out of ideas - I need some inspiration!
Thanks for any suggestions
#Salesforce Developer
Hi All,
Thanks for all the suggestions.
It was resolved in the end with an SF Support Case, and they 'fixed' (with no real detail) some records in the Sandbox. I asked for more info but nothing useful was provided, and was told it was something I couldn't have done anyway.
So, sounds like some sort of data corruption when the Sandbox was refreshed.