Formula Class
Contains methods to get a builder for creating a formula instance and to update all formula fields on the input SObjects.
Use the Formula class in conjunction with the FormulaBuilder and FormulaInstance classes in the FormulaEval namespace.
See Formula Evaluation in Apex.
This example creates a formula instance using Formula.builder() and the FormulaBuilder methods.
The following are methods for Formula.
-
Creates an instance of
FormulaBuilderfor configuring the formula with formula expression, context type, and output data type as inputs. -
Updates (recalculates) all formula fields on the input SObjects.
Creates an instance of FormulaBuilder for configuring the formula with formula expression, context type, and output data type as inputs.
public static formulaeval.FormulaBuilder builder()
Type: FormulaEval.FormulaBuilder
Updates (recalculates) all formula fields on the input SObjects.
public static List<System.FormulaRecalcResult> recalculateFormulas(List<SObject> sobjects)
- sobjects: Type: List<SObject> List of sObjects whose formula fields are to be recalculated.
Type: List<FormulaRecalcResult Class>
Recalculate formula fields on new or queried SObjects. If all data is present on the SObjects, SOQL limits are not affected. If the data required to evaluate a formula field is missing, that data is retrieved and limits are changed accordingly.
The new formula values are stored in the SObjects themselves and overwrite previous values of formula fields.