when we go for process builder and when we go for trigger? - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
mahe reddymahe reddy 

when we go for process builder and when we go for trigger?

Pruthvi Raj KankunthalaPruthvi Raj Kankunthala
@Mahe: Here are the capabilities and cons. 
  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
  2. Simple triggers like populating a lookup field based on certain criteria can now be automated in Process Builder
  3. Launch an automated flow.
  4. 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:
  • 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.
  • Process Builder cannot handle delete and undelete DML. Whereas Apex triggers can handle all DML operations.
  • 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.
  • It is all or none in case of Process Builder failure. But with Apex triggers partial success is possible.
  • 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.
Source: https://blogs.perficient.com/salesforce/2017/06/13/when-to-use-process-builder-or-apex-triggers-to-automate/

Also check this article too https://www.slideshare.net/ProQuestIT/process-builder-vs-trigger
Dnyaneshwar AghawDnyaneshwar Aghaw

Hi Mahe,
Check below articles.
When to Use Process Builder or Apex Triggers to Automate

sakshi nagpalsakshi nagpal
Process builder is configuration , and trigger is code,we should always give first preference to process builder,if functionality cannot be accomplished with process builder go for a trigger.
 What a process builder can do-:
  • Assign tasks
  • Update related records
  • Create a record
  • Send an email
  • Launch or consolidate workflows
  • Business processes
What a process builder cannot do-;
  • Delete records
  • Clone a record and it’s values
  • Send an outbound message without code
You can launch a flow from process builder  and do almost anything that can be done through trigger example updating unrelated records.
Remember one thing process builder is bulkified, however flow is not bulkified.please consider this before using flow.

Bulkify Process Builder(delivered)
 Bulkify Process Builder - Part 2(PRODUCT TEAM REVIEW)\