-
Notifications
You must be signed in to change notification settings - Fork 188
Open
Description
Overview
I was just trying to demo the DMLFinalizer functionality. Below is my code and cmdt for the Opportunity. I'm expecting the Finalizer to simply call System.debug but I don't see my USER_DEBUG line in the debug logs. This is in a new Developer Edition sandbox with TAF, Apex-rollup, and Nebula Logger installed as unlocked packages.
Trigger
trigger OpportunityTrigger on Opportunity (
before insert,
before update,
after insert,
after update
) {
new MetadataTriggerHandler().run();
}Trigger Action
public with sharing class Opportunity_SalesRules implements TriggerAction.BeforeInsert, TriggerAction.BeforeUpdate {
public static final String PROSPECTING_STAGE = 'Prospecting';
public static final String INVALID_STAGE_INSERT_ERROR = 'New Opportunities must start in the Prospecting stage.';
public void beforeInsert(List<Opportunity> newOpportunities) {
for (Opportunity newOpp : newOpportunities) {
if (newOpp.StageName != 'Prospecting') {
Logger.debug(INVALID_STAGE_INSERT_ERROR, newOpp);
newOpp.addError(INVALID_STAGE_INSERT_ERROR);
}
}
}
public static final String CLOSED_WON_STAGE = 'Closed Won';
public static final String INVALID_STAGE_UPDATE_ERROR = 'Closed Won Opportunities cannot be moved to another stage.';
public void beforeUpdate(List<Opportunity> newOpps, List<Opportunity> oldOpps) {
Map<Id, Opportunity> oldOppMap = new Map<Id, Opportunity>(oldOpps);
for (Opportunity newOpp : newOpps) {
Opportunity oldOpp = oldOppMap.get(newOpp.Id);
if (oldOpp.StageName == CLOSED_WON_STAGE && newOpp.StageName != CLOSED_WON_STAGE) {
Logger.debug(INVALID_STAGE_UPDATE_ERROR, newOpp);
newOpp.addError(INVALID_STAGE_UPDATE_ERROR);
}
}
}
}Account Finalizer
public with sharing class Account_DmlFinalizer implements TriggerAction.DmlFinalizer {
public void execute(FinalizerHandler.Context context) {
System.debug('Account DML Finalizer executed.');
Logger.saveLog();
}
}Opp Finalizer
public with sharing class Opportunity_DmlFinalizer implements TriggerAction.DmlFinalizer {
public void execute(FinalizerHandler.Context context) {
System.debug('Opportunity DML Finalizer executed.');
Logger.saveLog();
}
}Opportunity Trigger Setting
Finalizer Config
Account Finalizer Config
Opp Finalizer Config
Two Finalizers

Metadata
Metadata
Assignees
Labels
No labels