top of page

Update multiple child records at once using Visual Flow

Oct 21, 2018
2 min read

Hola Ohana!

This article is about demonstrating how to update multiple child records using a Visual flow.

For understanding purposes, we will keep our use case very simple and specific.

Use Case:

We would like to update the stage of all child opportunities related to an Account record to a specific value.

So let’s get started!

Step 1: We will start off by creating some flow variables.

var recordId
var DRC
var Picklist
var OpportunitiesToUpdate
var Child Opps

Step 2: Next, we will create a screen, using Screen element. This screen element will contain a “Multi-Select Checkboxes” field and a “Dropdown List” field.

Screen-Screen to select Opps to update
Screen-Screen to select Opps to update-Select_the_Opportunities_to_update-DRC
Screen-Screen to select Opps to update-Picklist

Step3: Now, we use a Decision element to check if the user selected has at least one record and the Stage value as well.

Decision-Check if Opportunities and Stage is selected

Step 4: Based on the output of decision element: If the output is False, implying user either didn’t select any stage or selected at least one Opportunity record, we display a message using a screen element.

Screen-ErrorMessageScreen

Step 5: If the output of decision element comes out to be true, i.e. user selected at least one record and stage value, we proceed with our flow and query all the child Opportunity records using Fast lookup element. Consequently followed by a Loop element to iterate over the queried records.

Fast Lookup - Get Child Opportunities_A
Fast Lookup - Get Child Opportunities_B
Loop-Loop through all the Child Opps

Step 6: In our loop, we shall first check, using a Decision element, if the current loop element(Opportunity record) is one of the selected Opportunities or not. If yes, then we assign the stage selected by the user to the stage of loop element using a Assignment element and then add the loop element to the collection variable.

Decision-Check if the Opportunity is selected
Assign- Assign Stage
Assign-Add Opportunity to Update List

Step 7: After adding the loop element to the collection variable, we update all the records in collection variable using a Fast update element, followed by a success message on a Screen element.

FastUpdate-Update Opportunities
Screen-SuccessMessageScreen

With that, completes our flow. And finally our complete flow looks like:

Complete Flow

Save and Activate your flow.

Step 8: Our job isn’t done yet. We need to create a quick action to call our flow.

  • Setup -> Object Manager -> Account -> Buttons, Links and Actions.

  • Click on New Action.

Action Type: FlowFlow:

Choose your flow from the dropdown

  • Give it a suitable label and save it.

  • Now go to page layouts and add your quick action to the “Salesforce Mobile and Lightning Experience Actions” section and save it.

And voila! We are good to go.

Quick Demo

Demo

With this, you can extend your flow not just to update stage but any other field, even multiple, depending upon your business logic.

-Thank you!

 
 
 

Comments


bottom of page