How to Update Related Records using Salesforce Flow

In Salesforce, flows are the most powerful automation tool. They can perform various tasks, such as creating a record, field updates, sending emails, and custom notifications. After changing any value, we can update the child object records, which are related records from the parent object.

In this Salesforce article, we will learn about update related records using Salesforce Flow. We will see which flow we can use and how to update related records using Salesforce Flow with real-time scenarios and step-by-step explanations.

Update Related Records using Salesforce Flow

Which type of flow can we use to update related records using flow in Salesforce?

In Salesforce flow, we use record-triggered flow to create, update, or delete records. Here, we want to update related records, so we have to select Record-Trigger to flow.

Scenario Related Records using Salesforce Flow

While working as a Salesforce Admin for a US-based Organization that provides software solutions, I was assigned the task whenever the Active_c field is changed from Yes to No; all the opportunities of that particular account that are in the open stage should change to the “Close Lost.”

That means whenever any account active field changes to No, it means that the account will no longer be active now, and the account’s opportunity stages, which are open stages, need to change to “Close Lost”.

Pre-requisite: We need Active_c custom Picklist field with Yes and No values on the standard Account object.

Use Record Triggered to Update Related Records using Salesforce Flow

Using the above scenario and the following steps, we will see how to update related records using Salesforce Flow.

1. Log in to the Salesforce Org. -> Click on the Setup -> Home Tab -> In Quick Find Box, Search for Flows. You will see an option under Process Automation -> Click on Flows.

Update Related Records Using Salesforce Flow

2. Then, click on the New Flow button to create a new flow.

Update a Related Records Using Salesforce Flow

3. We want to update the related records from its parent account, so we have to select the Record-Trigger flow. Then, click on the Create button.

4. When you click the create button, you have to select the object that triggers the flow when we update the value.

See also  How to Use Lightning Email Templates in Salesforce Flow

In our scenario, when we change the Active_c field value, that time flow will trigger. That’s why, in the Object field, I have selected the Account object because the Active_c field is on the Account object. In Configure Trigger, I have selected A Record is Updated because when we update the record, the flow should trigger.

How to Update a Related Records Using Salesforce Flow

5. Specify entry conditions to reduce the number of records that trigger the flow and the number of times it is executed. Minimizing unnecessary flow executions helps conserve your organization’s resources.

If you create a flow that’s triggered when a record is updated, we recommend first defining entry conditions. Then select the Only when a record is updated to meet the condition requirements option for When to Run the Flow for Updated Records.

Then, we have to Set Entry Conditions, and in the Condition Requirement option, we have to select All Conditions Are Met(AND) because following both conditions should meet the criteria.

Here, the flow has to trigger only when the Active_c field value is No and when the user changes the Active_c value. When these two conditions are met, only then will trigger.

How to Update Related Object Records Using Salesforce Flow

6. Then, here, we have to select When to Run Flow for Updated Records, and we have the following two options:

  • Every time a record is updated and meets the condition requirements: When you select this option, every time you update the record, then the flow will trigger.
  • Only when a record is updated to meet the condition requirement: In this option, only selected conditions that meet the criteria will flow trigger.

In the Optimize the flow for option here we have to select Action and Related Records because we want to update related object records.

How to Update Related Records Using Salesforce Flow

7. Now, we have to add an element to update a record in the related object. For that, we need to click on the + icon, then click on the Update Records option, and enter the following information.

  • Label: enter the label this will display on the flow canvas.
  • API name: This will automatically populate after clicking the API Name field.
  • Description: This is optional; you can give a short intro about this update record element.
  • How to Find Records to Update and Set Their Values: Using this option, we can fetch records by related record ID, and here, I have selected specific conditions to identify records and set fields individually option.
Create a Related Records Using Salesforce Flow

8. Now, on which related object record we have to update, enter that object name in the Object field. As per our scenario here, I have to select the Opportunity object.

See also  Auto-Launched Flow in Salesforce | How to Create Auto-Launched Flow In Salesforce

Then, in the Filter Opportunity Records, we have to add conditions for on which basis the record should be filtered.

Here you can see the Field option in that we have to select Opportunity fields. You can see the following conditions:

  • First Condition: Here, I have mapped Opportunity AccID with the parent AccountID.
  • Second Condition: Stage Name should not equal to Closed Won.
  • Third Condition: In this condition, the Stage Name should not equal Close Lost before updating the Active_c field on the Account object.
Create Related Object Records Using Salesforce Flow

9. Now we have to Set Field Values for the Opportunity Records for that select the field that you want to update from the opportunity object. Here, I want to update StageName, and this is the Picklist field so I can select a value in the value field.

As per our scenario, we have to update the StageName to be equal to Close Lost.

Create Update Related Object Records Using Salesforce Flow

10. After that, first save the flow. For that, you can see the Save button. Click on it and then click on the Debug button. Then click on the Activate button; always remember before activating the flow, first debug it. It’s good practice to use flow.

Field Update Using Salesforce Flow

11. After setting up all labels and conditions, click the Save button to save the flow. For that, we need to enter the Flow Label; here, I have entered the Update related records. The API Name will automatically populate as we click the text box. The Description is optional; we can introduce our flow Shortly.

Field Update in Salesforce Flow

12. To check how the flow is working, go to the Account object. Here, you can see that the Active field has a Yes value.

Related Record Update Using Salesforce Flows

13. When the Account Active field is Yes, then you that time you can see that all related opportunity records stages are different. Now, I will change the Active field to No, and you will see the changes in the next step.

Related Record Update Using Salesforce Flow

14. As I change the Active field to No, you can see all opportunities related to that account. The stages change to Close Lost except for one opportunity because, in the filter opportunity, we have added conditions for those fields with the Closed Won stage that will not change.

Related Record Update in Salesforce Flow

This is how we can update related records using the Salesforce Flow.

See also  How to Use Salesforce Flow in List View

Conclusion

I hope you have an idea about about updating related records using Salesforce Flow. We have seen which flow we can use and how to update related records using Salesforce Flow with real-time scenarios and step-by-step explanations.

You may like to read: