Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

FormulaRecalcResult Class

The return type of the Formula.recalculateFormulas method.

Namespace

System

Usage

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.

Example

This example assumes that you have a formula field called divide__c with formula “1 / LEN(Name).

1List<Account> accounts = [SELECT Name FROM Account WHERE Name='Acme'];
2accounts[0].Name = '';
3List<FormulaRecalcResult> results = Formula.recalculateFormulas(accounts);
4FormulaRecalcResult result0 = results[0];
5FormulaRecalcFieldError fieldError = result0.getErrors()[0];
6System.debug(fieldError.getFieldName()); // 'divide'
7System.debug(fieldError.getFieldError()); // 'Division by zero'

FormulaRecalcResult Methods

The following are methods for FormulaRecalcResult.

getErrors()

If an error occurs during formula recalculation, an array of one or more database error objects, along with error codes and descriptions, is returned.

Signature

public List<System.FormulaRecalcFieldError> getErrors()

Return Value

Type: List<FormulaRecalcFieldError Class>

getSObject()

Returns the sObject with formulas recalculated.

Signature

public SObject getSObject()

Return Value

Type: SObject

isSuccess()

Returns a Boolean value that is set to true if the formula recalculation process completed successfully; otherwise, it is set to false.

Signature

public Boolean isSuccess()

Return Value

Type: Boolean