Activity Forums Salesforce® Discussions Where we can use Process Builder and not triggers and vice-versa in Salesforce?

  • Piyush

    Member
    August 9, 2019 at 6:42 am

    Hi Somendra,

    I hope this will help you to differentiate between Process Builder or Apex Triggers.

    1-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:

    -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.Validation: Processes do not trigger validation rules and can, therefore, invalidate data.
    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.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos