A few days back Chris Edwards and Michael Gill Flow and Process Builder expert have written a blog post on Use Flow to Report on the Most Recent Record. I had spent an ample amount of time to figure it out how we can achieve it through Process Builder. Let’s start with a business use case
Business Use case
Tamara McCleary is working as a System administrator at Universal Containers (UC). At UC they are using Salesforce to manage Opportunities and Quotes. In Salesforce each Opportunity can have multiple Quotes. Whenever a Quote is accepted by the customer, then auto update Description field to Final Quote. They also want to update the related Quote Status from the same Opportunity to Denied.
Solution for the above business requirement
There are multiple ways to solve the above business requirement. You can either use Apex trigger, Combination of Flow & Process Builder and few more. To solve this requirement, we will use Process Builder. This article will help you to understand how you can use Process builder to update related records for the complex business scenario. Follow the below instructions to create a Process for the above business requirement
1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder
2. To create a new process from scratch, click on the New Button available on Process Management page, A popup will open where you have to enter Name (Enter Update Quotes as name), API Name and Description as shown in the below screenshot
3. Once you are done click on the Save button, it will redirect you to Process canvas. Click on Object node to add object, Select Quote object, in this case, and set the evaluation criteria, Please refer to the following screenshot for more details
4. The next step is to define Process criteria. For this click on Add Criteria node, Enter Criteria Name, Set filter conditions (Similar to Rule Criteria in WFR),
- For Criteria action select Filter conditions are met
- Enter criteria [Quote].Status= Accepted
- For Filter conditions select All of the conditions are met (AND), Please refer to the following screenshot for more details
5. Next step is to update the related Quotes from the same Opportunity to Denied. For this use, we will use Immediate action, Update Records. To select the related quotes , lease refer to the following screenshot for more details
Then select the fields Status and for value select Denied fields, as shown in the following screenshot
6. Once you are done click on the Save button, it will redirect you to Process canvas. Now we have to add one more Immediate action into the Process to update the accepted Quote Description & Status field. For this use Update Records action. Use Field Picker to select the field Description and Text Entry field to enter a comment or sentence. Please refer to the following screenshot for more details
7. Finally the Process will look like the following screenshot, don’t forget to active the Process by clicking on the Activate button.
It’s time to test this Process
Now onwards if a business user updates the Quote Status to Accepted, Process builder will automatically update the Quote Description and another Quote Status to Denied.
1. Currently, there are four Quotes attached to Opportunity “Universal Container” as shown in the following screenshot
2. Now we will update the Quote “UC RFCT V1” Status to Accepted, as shown in the following screenshot
3. Once you are done, click on the Save button and check the Quotes status, as shown in the following screenshot
Note: -I will suggest you Implement this first on your developer org test it and then move it to Production.