Receiving Error when querying for lookup fields while using sObject.recalculateFormulas() method.
Last updated 2 days ago ·Reference W-2861176 ·Reported By 185 users
Exception occurs when sObject.recalculateFormulas() is called and the query which retrieves the object contains reference fields.
FATAL_ERROR System.UnexpectedException: Opportunity: bad field names on insert/update call: Account
NOTE : If the fields are not updatable and they are in SOQL, it causes the error. Some special fields like IsPersonAccount for Account, IsClosed for Case on the standard objects are also not updatable, so it should cause the same issue as well.
1) Add a formula field on Case
2) Create an account record
3) Create a case record which has reference to 2)
4) Open developer console and invoke the apex code below from the Execute Anonymous Window
Case c = [select id , account.name from Case WHERE id='500xx000000Yl1I'];
Avoid retrieving lookup fields in SOQL queries that retrieves the target sObjects.
Reported By (185)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.