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
Baylor Peak 2Baylor Peak 2 

Process Flow or Trigger?

Hello, ya'll:)

I am still pretty new to Salesforce development but have definitely gotten my feet wet. We have run into a snag with a Process Flow we are building but not certain it is the right way to go in the first place.

To start, we’ve tried to set up a couple of Flows via Process Builder, but not getting them to work the way we want. We would like the Flow to automatically update the Status field of a Case via Email-to-Case when users/customers send a reply from an email response.

We have a new status we created called Response Received, and we would need any existing cases that get a new response via email to be updated to this status, including cases that are already in a closed status. Our objective is not to miss any emails that have been read with a status of closed.  A majority of follow-up to closed cases will be simple Thank You's, but sometimes the customer raises an actionable need in those replies and we don't want to miss those.

We almost got this working with a Process Flow but it was also updating new Email-to-Cases with Response Received when those should remain in New status.

I am sure an Apex Trigger could do what we want, but we would like to make it less complex which is why we opted to use Process Builder.

Can this be done with Builder the way we want or must we use an Apex Trigger? If we do need to use a Trigger, could ya'll please point me in the right direction on how I would go about building this Trigger, please? 

Ajay K DubediAjay K Dubedi
Hi Baylor,

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 the 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 to this URL: https://success.salesforce.com/answers?id=9063A000000p7NiQAI    
 
http://www.adhiman.com/process-builder-vs-apex-triggers-choosing-between-automation-tools/  

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
Baylor Peak 2Baylor Peak 2
Thank you for the detailed response, but I am still not clear if you are saying Process Builder will or will not work for my issue?

It sounds like I can't use Process Builder for what I want to do, but I'm still not sure how to do this with a trigger then, because like I said I am still pretty new and not sure how I would build this trigger...: