top of page

How to mass update or delete child records from Related lists in Lightning using Flows?

Jan 28, 2020
2 min read

Hi! Glad to see you here. 😀

In lightning, mass action buttons on related lists have been frequently requested by our end users. If you are Dev, good for you because you will do some code magic to get it done. But as an Admin, you often might find yourself in a tough spot. Today we are here to get you out from one of those tough spots. 😎

As the title of the post is self explanatory, we will dive straight into a use case.

Use case

*there ain’t no better place than community to find an apt use case * 😎

Now that we know Raquel’s problem, let try to put a smile on her face.

Logic

The idea is to pass the IDs of the selected child records to a flow and then handle the rest of the logic inside the flow.

The main issue about this solution is that how do we pass the selected record Ids. Well, this issue no longer remains an issue thanks to Matt and Niel, admins of www.xbaf.com. A great find by them: www.xbaf.com//flow-list-buttons

Before continuing further, make sure you read the article.

Done reading? Well, I hope so. Now let’s see how we can mass delete the addresses of the selected contacts in the flow.

Step 1: Create a flow variable called ‘ids’ of Text collection type and mark it as ‘Available for Input’.

Note: Make sure to name the variable exactly as it is.

Step 2: Create loop element to loop over the collection of IDs. Addtionally, create a variable of Text type and use that as Loop Variable.

Step 3: Create two variables, a record variable and record collection variable, both of object type Contact.

Step 4: Using an Assignment element, set the Id and address fields of the record variable with ID and NULL respectively.

Step 5: Add the contact record variable to the Contact type collection variable using another assignment element.

Step 6: And finally update the records using the collection variable in the Update Records element

Final flow

Once the flow is created, create a list type URL button on Contact as shown. And then add this button to the Contact related on the account page via Account page layout.

And you are all set to run your flow! 😀

Hope you find it useful! Thank you for being an awesome reader! Subscribe to this blog for receiving all the latest updates straight to your inbox. 🙂

 
 
 

Comments


bottom of page