And no, if you're thinking I'm writing to a formula field, that's not it - read on....
I've been seeing this error sporadically during an upsert on one, and only one, org.
Upsert failed. First exception on row 0 with id a1H00000000VR5lEAG; first error: UNKNOWN_EXCEPTION, Cannot set the value of a calculated field: []
I've done a search for "Cannot set the value of a calculated field" (in quotes) and, believe it or not, it comes up with just one unrelated response.
And no, it's not the obvious - I'm not setting the ID, and if you try to update a formula field, you get the error "Field is not writable" which, as you would expect, returns gazillions of hits when searched.
In terms of being sporadic - it might appear once every week or two. So we're talking maybe one error in >100K upserts on this object. On this one org - nowhere else.
Notice that it doesn't actually say what field is impacted. And, to add to the confusion - this is an upsert of a custom object in a managed package. There are no triggers or workflows on the object.
I'm very much at a loss - without the ability to reproduce it, contacting SFDC support is likely to be a waste of time. So, if anyone has seen this before and has any suggestions or context to provide, I'd greatly appreciate it.
Dan
DMLExceptioncan you use the getDmlFieldNames() method to help isolate the fields. Maybe throw another exception and include the full sObject that was being inserted (Convert to JSON and append to the message). – Daniel Ballinger Apr 02 '14 at 08:19