Update Related Quotes to Denied Except for the One That Was Accepted

Update Related Quotes to Denied Except for the One That Was Accepted

Last Updated on April 3, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

How do I use automation to update an objects’ other related records?

Objectives:

After reading this blog, you’ll be able to: 

  • Use Salesforce to automatically update quotes associated with an Opportunity
  • Use the decision element to check the quote status 
  • Define criteria so specific records receive specific updates
  • and much more

Business Use case

Tamara McCleary is working as a System Administrator at Gurukul on Cloud (GoC). They use Salesforce to manage Opportunities and Quotes, and each Opportunity can have multiple Quotes. Whenever a customer accepts a Quote, all other Quote records related to that opportunity should have the Status updated to Denied

Automation Champion Approach (I-do):

To solve this requirement, we will use the After-save Record-Triggered Flow. Check out this article to understand why we are using after-save record-triggered flow for this scenario.

Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understand it.
Let’s begin building this automation process.

Guided Practice (We-do):

There are 3 steps to solve Tamara’s business requirement using Record-Triggered Flow. We must:

  1. Define flow properties for record-triggered flow
  2. Add a Decision element to check quote status
  3. Add an Update Records element to update related quote status to denied 

Step 1: Define Flow Properties

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Record-Triggered Flow option, click on Create and configure the flow as follows:
    1. Object: Quote
    2. Trigger the Flow When: A record is created or updated
    3. Set Entry Criteria
      1. Condition Requirements: None
    4. Optimize the Flow For Action and Related Records
  5. Click Done.

Step 4: Using Decision Element to Check if the Quote Status Equals Accepted 

Now we will use the Decision element to check the quote status to ensure that it is equal to Accepted. 

  1. On Flow Designer, click on the + icon and select the Decision element. 
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Under Outcome Details, enter the Label the API Name will auto-populate.
  4. Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
    1. Row 1:
      1. Resource: {!$Record.Status}
      2. Operator: Equals
      3. Value: Accepted

The reason why we would select the Yes checkbox for the question is — Only if the record that triggered the flow to run is updated to meet the condition requirements — is to allow the record-triggered flow to execute the actions only if the record meets the criteria now, but the values that the record had immediately before it was saved didn’t meet criteria. This means that these actions won’t be executed when irrelevant changes are made.

Step 3: Add Action – Update Records

The next step is to update the related quote status to denied. We will use the Update Records element. 

  1. On Flow Designer, below the Accepted node, click on the +icon and select the Update Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. For How to Find Records to Update and Set Their Values select Specify conditions to identify records, and set fields individually
  4. Object: Quote
  5. Select All Conditions Are Met (AND)
  6. Set Filter Conditions
    1. Row 1:
      1. Field: OpportunityId
      2. Operator: Equals
      3. Value: {!$Record.OpportunityId}
    2. Click Add Condition
    3. Row 2:
      1. Field: Status
      2. Operator: Does Not Equal
      3. Value: Accepted
  7. Set Field Values for the Opportunity Records
    1. Row 1:
      1. Field: Status
      2. Value: Denied
  8. Click Done.

In the end, Tamara’s Flow will look like the following screenshot:

Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 54
  5. Interview Label: Update Related Quotes to Denied {!$Flow.CurrentDateTime}
  6. Click Save.

Almost there! Once everything looks good, click the Activate button.  

Note:- Before you activate your flow, you will want to make sure that you have assigned data in the correct format because Salesforce Flow obeys validation rules. If some fields are required by using validation rules, then make sure you have added those fields. Conversely, if some fields are required on the page layout, you can ignore those fields. 

Proof of Concept

Now onwards, when a business user updates the Quote Status to Accepted, the Record-triggered flow will automatically update the Quote Description and the Status on all other quotes to Denied.

  1. Currently, there are three Quotes attached to Opportunity Deer Valley Corp as shown in the following screenshot
  2. Now we update the Status on Quote 1 to Accepted and click Mark as Current Status
  3. Navigate back to the Opportunity to confirm other records are changed.

Independent Practice (You-do):

Create a Salesforce Flow that will de-select any other Primary Contacts when a new one is selected. 

Note: Start by creating a checkbox for ‘Primary Contact’ on the Contact object. 

Formative Assessment:

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

12 thoughts on “Update Related Quotes to Denied Except for the One That Was Accepted

  1. I tried this with a similar scenario and it did not work because of a validation rule for another field on the child object. I deleted the validation rule and the flow worked fine. Any tips on how to work around the validation rule, so I don’t have to delete it. Thanks so much for all your posts, I learn a lot from them!

  2. Hi Rakesh,

    I am facing a issue when working on similar kind of scenario.

    I have 2 process one on account and one on contact.

    contact process is updating one field of all the related contacts and one field of the account related with that contact.

    Account process is updating one field on 2 contacts. (as per the business rules,it is always 2 not more than that)

    Issue is when account process is fired all contacts get updated, how can i stop the contact process ?

  3. Hi Rakesh ,

    Excellent! i have follow the same steps and testing but my other quotes not denied can you pls help out.

    Thanks
    Mayur

      1. Hi, Rakesh, I suppose I figured out what’s wrong here. Step 5, in the object selection screenshot we see ‘Quote ID’ in the end, but actually it should be ‘Quotes’ – the same as in the next screenshot below. I failed at first too, but now it works as expected.
        Many thanks for such a valuable course!

  4. Excellent! Got it! One thing, I was not able to add the Status field on the Page Layout of Opportunity. I tried going to Quote/Search Layout and also Quote/Search Filter. But, nevertheless, I could click on each quote and see the results of the status changed to Denied when I status of one of the Quotes was chosen as Accepted. Thanks!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.