You need to sign in to do that
Don't have an account?
Marcio Fritsch
RecalculateFormulas method does not work with Master-Detail field picked.
Recently I have tested ApexPages.StandardSetController method and used .save method and worked fine. However I have changed to add new Calculated fields and tried to use .RecalculateFormulas() available for sobject and I faced a message error:
Unable to create/update fields: <sobject>. Please check the security settings of this field and verify that it is read/write for your profile or permission set.
I think there is nothing regarding to this above once I just took out the .save() method and just invoked the recalculateFormulas(). If I just take out the master_detail_field from my query, it works.
Code sample below:
...
ApexPages.StandardSetController([SELECT id, name, Master_detail_Field__c FROM sobject])
...
for(sobject s: setRecords.getrecords()){
s.recalculateFormulas();
}
Unable to create/update fields: <sobject>. Please check the security settings of this field and verify that it is read/write for your profile or permission set.
I think there is nothing regarding to this above once I just took out the .save() method and just invoked the recalculateFormulas(). If I just take out the master_detail_field from my query, it works.
Code sample below:
...
ApexPages.StandardSetController([SELECT id, name, Master_detail_Field__c FROM sobject])
...
for(sobject s: setRecords.getrecords()){
s.recalculateFormulas();
}
Seems like it is related to this Known Issue: https://success.salesforce.com/issues_view?id=a1p300000008bvw
if so, check the "Affects me" check box :)
"This issue happens if there are fields which are not updatable in SOQL" (src: StackExchange (http://salesforce.stackexchange.com/questions/100627/winter-16-recalculateformulas-fails-when-sobject-has-relationship-fields))