We have the Salesforce CPQ Billing package installed in our organization without any problems.

Since the new Winter '24 release, we have sometimes encountered deployment errors in our org due to the random execution order of the Salesforce Billing trigger versus our own invoice trigger. The two triggers are on the blng__Invoice__c object.

It's not possible to control the execution order of two different triggers on the same object. Is there a workaround in this specific situation to force the CPQ trigger to execute before our own trigger?

1 Answer 1


There's no direct method to control the order of triggers. To run your trigger after a "before save" trigger, you would need to use an "after save" trigger. To guarantee your trigger runs after an "after save" trigger, use a Record-Triggered Flow (After Save), which is guaranteed to run after all triggers. You can convert your existing code to an InvocableMethod so you don't have to rebuild your logic from scratch.

  • 1
    I didn't suggest this because you actually then have to commit the changes in two sequential DMLs and that's a really bad idea.
    – Phil W
    Nov 8, 2023 at 17:38
  • @PhilW Depends on if it's before or after. If you need to update the current record in a defined order, then yes, an extra DML would occur. Otherwise, if they're two after triggers, there would be virtually no overhead, minus the fact that one has to run a flow (a few ms or so).
    – sfdcfox
    Nov 8, 2023 at 20:57
  • 1
    Given the outline, there is a dependency between the packaged trigger and the local one. That suggests to me data changes from the package are needed in the local one. If it is for the triggered records, double DML. If it is for related records, double DML (which it would already be). Whichever it is, this is a bad solution. That said, it may be the only one of course.
    – Phil W
    Nov 8, 2023 at 21:47
  • @PhilW Don't worry, we're on the same page. I agree it's not ideal. The managed package should have a way to include custom Apex logic within its triggers. But if you don't have a proper API, you make a workaround.
    – sfdcfox
    Nov 8, 2023 at 22:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .