12

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

kibitzer
  • 3,434
  • 19
  • 25
  • 3
    If/when you catch the DMLException can 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
  • If the error is presented in a page and that org can be left in "Development Mode" (http://salesforce.stackexchange.com/questions/30094/no-log-for-visualforce-errors#30097) until the error occurs then the stack trace information output might help. – Keith C Apr 02 '14 at 11:52
  • I have to wonder if there isn't a field that requires encryption that's being upserted without first being encrypted. That might produce an error along those lines. I'd be looking at the types of fields on the object to see what's there that might be in the wrong format or requiring special handling of some sort like encryption. Tough one for sure. – crmprogdev Apr 02 '14 at 12:36
  • 1
  • It's not a DMLException - it's an Unknown exception. The idea of looking at the data being upserted is a good one - though tough in this case to implement (managed package will take a release cycle) 2. It's not on a page, it's being generated in a batch process and we're getting the Email notification. I do know exactly what line it's occurring on - it's an upsert DML operation 3. No encrypted fields on the custom object. Love the way you're all thinking though.
  • – kibitzer Apr 02 '14 at 16:42
  • I'm curious to learn if you got anywhere with this issue. Did SF Support provide any info around the error message? – smohyee Aug 31 '15 at 15:57
  • Wow - I'd forgotten all about this one. I haven't seen this error in a while, so I'm guessing whatever it is was some obscure platform bug that has since been resolved. Either that, or I shoved it into a try/catch block and am now ignoring it :-) – kibitzer Sep 01 '15 at 18:35
  • It may be due to rollup summary field please check there that rollup summary field exist or not. – Ravikant Kedia Oct 07 '15 at 02:53