Created
March 28, 2020 12:02
-
-
Save LokeshSagi/83bca61cd3770cf4043de95262e75b95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void saveDocuments() { | |
fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(new List<SObjectType> { SBQQ__Quote__c.SObjectType }); | |
// pass your Domain class name to getTriggerEvent method of fflib_SObjectDomain. | |
// Call disableAll() to disable all trigger contexts. | |
// Call individual contexts if need to disable in that way -- disableBeforeInsert(), disableBeforeUpdate(), disableAfterUpdate() etc | |
fflib_SObjectDomain.getTriggerEvent(Quotes.class).disableAll(); | |
// Do DML only if the trigger context is disabled. | |
if(!fflib_SObjectDomain.getTriggerEvent(Quotes.class).isEnabled(true, true, true, true, true, true)) { | |
System.debug(' -- Saving docpage -- '); | |
uow.commitWork(); | |
} | |
// Enable the trigger contexts after the DML. | |
fflib_SObjectDomain.getTriggerEvent(Quotes.class).disableAll(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apex Enterprise Patterns - Enable/Disable trigger contexts while doing DML operations. Check fflib_SObjectDomain class for more details.