function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kapil_KhandelwalKapil_Khandelwal 

Process builder vs triggers

I am confused between the two. When to use what!!! 
Please explain the difference between the two. Also present a use case where we can use process builder and not triggers and vice-versa.

Thanks in advance.
SandhyaSandhya (Salesforce Developers) 
Hi,

There are some blogs on this with the usecase for each. I would suggest you refer them.

https://blogs.perficient.com/2017/06/13/when-to-use-process-builder-or-apex-triggers-to-automate/
 
http://www.adhiman.com/process-builder-vs-apex-triggers-choosing-between-automation-tools/
 
https://www.slideshare.net/ProQuestIT/process-builder-vs-trigger
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
 
Ajay K DubediAjay K Dubedi
Hi Kapil,

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.

Refer this URL: https://success.salesforce.com/answers?id=9063A000000p7NiQAI    
 
http://www.adhiman.com/process-builder-vs-apex-triggers-choosing-between-automation-tools/  
       
Please mark it as best Answer if you find it helpful.
Please let me know if you have any query.

Thank You
Ajay Dubedi