Disable CPQ Triggers in Apex
You can manually disable Salesforce CPQ application logic when you update records. This
process is helpful when you’re updating your own custom field. It’s also helpful when you update a
record several times in one transaction and want triggers to run only on the last
iteration.
| Available in: Salesforce CPQ Summer ’16 and later |
To ensure that your org doesn’t run into operational issues when disabling triggers, test
thoroughly. Use the global Apex API TriggerControl—the same mechanism that Salesforce CPQ
uses internally—to manually disable CPQ triggers.
Methods
- global static void disable();
- Disables built-in CPQ triggers within the current transaction.
- global static void enable();
- Enables built-in CPQ triggers if they had previously been disabled.
- global static Boolean isEnabled()
- Returns true if CPQ triggers are currently enabled. Otherwise, returns false.
Example
1SBQQ.TriggerControl.disable();
2try {
3 // Do something simple and interesting without
4 // running triggers.
5 quote.MyStatus__c = ‘Red’;
6 update quote;
7} finally {
8SBQQ.TriggerControl.enable();
9}Example
1if (SBQQ.TriggerControl.isEnabled()) {
2 // Only run our logic if CPQ trigger logic is also enabled.
3 myRelatedObject.Quote__c = quote.Id;
4 insert myRelatedObject;
5}