Indicates the result and status of recalculating formulas on a single sObject. Holds a reference to the sObject and a list of all the fields that were recalculated.
This example assumes that you have a formula field called divide__c with formula “1 / LEN(Name).
List<Account> accounts = [SELECT Name FROM Account WHERE Name='Acme']; accounts[0].Name = ''; List<FormulaRecalcResult> results = Formula.recalculateFormulas(accounts); FormulaRecalcResult result0 = results[0]; FormulaRecalcFieldError fieldError = result0.getErrors()[0]; System.debug(fieldError.getFieldName()); // 'divide' System.debug(fieldError.getFieldError()); // 'Division by zero'
The following are methods for FormulaRecalcResult.
public List<System.FormulaRecalcFieldError> getErrors()
Type: List<FormulaRecalcFieldError Class>
public Boolean isSuccess()
Type: Boolean