Define Additional Conditions When Updating Records

Define Additional Conditions When Updating Records

Last Updated on April 2, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

How can I use automation to update open opportunities related to an account?


  • Use the decision element to check the account’s current status 
  • Define criteria so specific records receive specific updates
  • Use record-triggered flow to update other records related to an account

Business Use case

Steve Cartwright is working as a System Administrator at Universal Containers (UC). He has received a requirement from management, that whenever a customer is going out of business, then auto-update related Open opportunities to Lost.

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 2 steps to solve Steve’s business requirement using Record-Triggered Flow. We must:

  1. Create a custom checkbox field (Out of Business on Account) 
  2. Salesforce Flow Steps:
    1. Define flow properties for record-triggered flow
    2. Add a Decision element to check the account status 
    3. Add an Update Records element to update the related opportunities  

Step 1: Create a Custome Field – Out of Busines 

  1. Click Setup.
  2. In the User Interface, clicks on Object Manager.
  3. Navigate to Account | Fields & relationships and click on the New button.
  4. Click on the Checkbox data type.
  5. Enter Field Label the Field Name will auto-populate. 
  6. Click on the Unchecked for the Default Value.
  7. Add a field on the Page Layout and grant field access to the desired profiles. 
  8. Click Save.

Step 2.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: Account
    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 2.2: Using Decision Element to Check, if Account Out of Business Equals True

Now we will use the Decision element to check if the account out of business changed to True. 

  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.Out_of_Business__c}
      2. Operator: Equals
      3. Value: {!$GlobalConstant.True}
  5. When to Execute Outcome: Only if the record that triggered the flow to run is updated to meet the condition requirements.
  6. Click Done.

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 2.3: Add Action – Update Records

The next step is to update the open opportunity status to closed lost. We will use the Update Records element. 

  1. On Flow Designer, below the Yes 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: Opportunity
  5. Select All Conditions Are Met (AND)
  6. Set Filter Conditions
    1. Row 1:
      1. Field: AccountId
      2. Operator: Equals
      3. Value: {!$Record.Id}
    2. Click Add Condition
    3. Row 2:
      1. Field: IsClosed
      2. Operator: Equals
      3. Value: {!$GlobalConstant.False}
  7. Set Field Values for the Opportunity Records
    1. Row 1:
      1. Field: StageName
      2. Value: Closed Lost
  8. Click Done.

In the end, Steve’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 Open Opportunities to Lost {!$Flow.CurrentDateTime}
  6. Click Save.

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

Independent Practice (You-do):

Think about your own sales process. What are the additional actions we could add to this process?

Proof of Concept

Now onwards, if a business user updates an Account Out of business to True, then Record-triggered flow will automatically update related open opportunities to closed lost. 

  1. Currently, there are Two open Opportunities attached to Account Deer Valley Corp as shown in the following screenshot:
  2. Now we update the Out of Business on Account to Checked.
  3. Navigate back to the Account and check the status of Opportunity. Record-triggered flow automatically marked those open opportunities as closed lost.

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!

2 thoughts on “Define Additional Conditions When Updating Records

  1. Hi there – is it better to set a lot of limiting conditions in the Criteria node or just have a lot of Immediate Actions with conditions that further limit the list of records? Thank you!

Leave a Reply

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