Skip to content

UTIL_FormulaContext.OpportunityContext

Class

apex
global inherited sharing class UTIL_FormulaContext.OpportunityContext implements UTIL_FormulaFilter.INT_SObjectFormulaEvaluationContext

Implements: UTIL_FormulaFilter.INT_SObjectFormulaEvaluationContext

Formula evaluation context for Opportunity object. Provides typed access to Opportunity records in formula evaluations. Auto-detected by Trigger Action Framework when EntryCriteriaContextClassName__c is blank. Can also be used directly in custom Apex. Formula Variable Names: oldRecord, newRecord

Since: 1.0

Example:

apex
// Trigger Action Framework formulas:
// newRecord.StageName <> oldRecord.StageName
// newRecord.Amount > 100000 && newRecord.StageName = "Closed Won"
// Direct Apex usage:
FormulaEval.FormulaInstance formula = Formula.builder()
    .withFormula('newRecord.IsClosed && newRecord.IsWon')
    .withReturnType(FormulaEval.FormulaReturnType.BOOLEAN)
    .withType(UTIL_FormulaContext.OpportunityContext.class)
    .build();
UTIL_FormulaContext.OpportunityContext context = new UTIL_FormulaContext.OpportunityContext();
context.setContext(null, opportunity); // null = no old record (insert scenario)
Boolean matches = (Boolean)formula.evaluate(context);

See Also: UTIL_FormulaFilter.INT_SObjectFormulaEvaluationContext


Fields

FieldDescription
global Opportunity newRecordOpportunity record state AFTER DML (null on delete).
global Opportunity oldRecordOpportunity record state BEFORE DML (null on insert).

Field Details

newRecord

apex
global Opportunity newRecord

Type: Opportunity

Opportunity record state AFTER DML (null on delete).

Since: 1.0

Example:

apex
Opportunity value = instance.newRecord;

oldRecord

apex
global Opportunity oldRecord

Type: Opportunity

Opportunity record state BEFORE DML (null on insert).

Since: 1.0

Example:

apex
Opportunity value = instance.oldRecord;