Skip to content

UTIL_FormulaContext.LeadContext

Class

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

Implements: UTIL_FormulaFilter.INT_SObjectFormulaEvaluationContext

Formula evaluation context for Lead object. Provides typed access to Lead 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

Example

apex
// Trigger Action Framework formulas:
// newRecord.Status = "Working"
// newRecord.LeadSource <> oldRecord.LeadSource
// Direct Apex usage:
FormulaEval.FormulaInstance formula = Formula.builder()
    .withFormula('newRecord.IsConverted = false && newRecord.Status = "Qualified"')
    .withReturnType(FormulaEval.FormulaReturnType.BOOLEAN)
    .withType(UTIL_FormulaContext.LeadContext.class)
    .build();
UTIL_FormulaContext.LeadContext context = new UTIL_FormulaContext.LeadContext();
context.setContext(null, lead); // null = no old record (insert scenario)
Boolean matches = (Boolean)formula.evaluate(context);

See Also: UTIL_FormulaFilter.INT_SObjectFormulaEvaluationContext


Fields

FieldDescription
global Lead newRecordLead record state AFTER DML (null on delete).
global Lead oldRecordLead record state BEFORE DML (null on insert).

newRecord

apex
global Lead newRecord

Type: Lead

Lead record state AFTER DML (null on delete).

Example

apex
Lead value = instance.newRecord;

oldRecord

apex
global Lead oldRecord

Type: Lead

Lead record state BEFORE DML (null on insert).

Example

apex
Lead value = instance.oldRecord;