mitchspano/trigger-actions-framework

Bypass Trigger Action from another Trigger Action

Opened this issue · 1 comments

Hello Mitch,

Please, consider next use case: I have two trigger actions on Before Update on the same object. As a result of validation in the first TA, I want to bypass execution of second. Is it possible?

Thank you,
Alex

Yes, you can use this step from the doc:

Bypass Apex classes using System.Type:

public void insertOpportunitiesNoRules(List opportunitiesToInsert) {
MetadataTriggerHandler.bypass(TA_Opportunity_StageInsertRules.class);
insert opportunitiesToInsert;
MetadataTriggerHandler.clearBypass(TA_Opportunity_StageInsertRules.class);
}
Bypass Flows using Flow.Interview:

public void updateContactsNoFlow(List contactsToUpdate) {
TriggerActionFlow.bypass(Flow.Interview.Contact_Flow.class);
update contactsToUpdate;
TriggerActionFlow.clearBypass(Flow.Interview.Contact_Flow.class);
}