Skip to content

Instantly share code, notes, and snippets.

@LokeshSagi
Created March 28, 2020 12:02
Show Gist options
  • Save LokeshSagi/83bca61cd3770cf4043de95262e75b95 to your computer and use it in GitHub Desktop.
Save LokeshSagi/83bca61cd3770cf4043de95262e75b95 to your computer and use it in GitHub Desktop.
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();
}
@LokeshSagi
Copy link
Author

Apex Enterprise Patterns - Enable/Disable trigger contexts while doing DML operations. Check fflib_SObjectDomain class for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment