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
Miguel Nuñez Díaz-MontesMiguel Nuñez Díaz-Montes 

Error when trying to deserialize CaseHistory json string

Hello,

I'm trying to deserialize CaseHistory from a String but im getting an unhandled error

Running this code in an anonymous console produces the error:

CODE:

String caseHistoryString = JSON.serialize([SELECT Id, CaseId, OldValue, NewValue FROM CaseHistory WHERE CaseId = '5004100000KERwkAAH']);

JSON.deserialize(caseHistoryString, List<CaseHistory>.class);

ERROR:

16:40:05:040 FATAL_ERROR System.UnexpectedException: Salesforce System Error: 1379890468-29928 (482212380) (482212380)

I have also tried to deserialize this other query and I'm not getting any error, so seems that the cause must be the OldValue, NewValue fields

String caseHistoryString = JSON.serialize([SELECT Id, CaseId, CreatedDate FROM CaseHistory WHERE CaseId = '5004100000KERwkAAH']);

JSON.deserialize(caseHistoryString, List<CaseHistory>.class);

Thank you,
Miguel
James (CloudAnswers)James (CloudAnswers)
I'm running into the same issue on API 48.

I found that if you null out the OldValue and NewValue in JSON you won't that exception, so it's probably some protected/private logic that is used in the OldValue and NewValue getters that we can't figure out.  Those fields can represent String, Boolean, Currency, etc. ~ so I tried to hunt around for the hidden fields but had no luck: OldValueString, OldValueStr, OldValueS, OldString, OldStr, etc.

I tried in APIs back to 44 with no luck either.