Skip to main content


When to Use Process Builder or Apex Triggers to Automate

Salesforce offers multiple tools to automate your company’s business processes. Oftentimes we run into confusion deciding whether to choose Process Builder or Apex triggers when both are capable of doing some of the same functions. Let’s take a closer look at some of the pros and cons of using Process Builder compared to Apex trigger.

Process Builder – Pros:

We recommend starting with Process Builder, especially for processes that can be simplified to if/then statements. Below are some ideal scenarios for using it:

  1. Process Builder can do the following actions without Apex code:
    • Create records and set field values
    • Update related records
    • Create Chatter posts
    • Send an email
    • Create an approval
    • Simple triggers like populating a lookup field based on certain criteria can now be automated in Process Builder
  2. Launch an automated flow.
  3. Call an Apex class.

Process Builder – Cons:

Below are some limitations to using Process Builder and the advantages of using Apex triggers to address these particular scenarios:

  1. Process Builders cannot handle before DML It executes after a record has been created or updated. Whereas Apex triggers can handle both before and after DML operations.
  2. Process Builder cannot handle delete and undelete DML. Whereas Apex triggers can handle all DML operations.
  3. An error reported in Process Builder is more generic which makes it difficult to find the origin of the error. With Apex triggers, exception handling can be made more specific.
  4. It is all or none in case of Process Builder failure. But with Apex triggers partial success is possible.
  5. Whenever a particular use case is not possible using Process Builder, consider using Apex triggers. For example, consider the below use case:-

A custom field on a Parent object which is based on the field related to the max (roll up) among the child records. Since roll-up functionality involves insert, update, delete and undelete operations, using an Apex trigger is the best option in this scenario.

Thoughts on “When to Use Process Builder or Apex Triggers to Automate”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Prabha Kannan

More from this Author

Follow Us