Use Case: Get a List of Names of Related Records to a Field
A while ago we published a Use Case to create a custom roll-up summary, but it focuses on numerical calculation. Today we will show you how to build the flows If you want to get a list of related records and their names. We will also use a different approach than the previous custom roll-up summary solution.
* Big thanks to Ivan Kovacek for sending in the case!
Lulu Mobile uses standard Account and Case objects. Even though they have a Case related list on the Account page, they still want to have a field to show all the case numbers that the Account has. This helps them search the Account for the case faster in a report. They have already created the field called “All Case Numbers”.
The flow should run whenever a case is created, the case number is updated, or a case is deleted. Different from the previous post, we will create two flows – one handles case creation and update, and the other one handles deletion.
The benefit is that these two flows are nearly identical, so it’s easier to build and maintain. The downside is that if you often edit the child records (ex. Case) in bulk, you might hit the governor’s limits by editing the parent record (ex. Account) more than 12 times.
Thus, carefully evaluate your organization’s needs and choose the solution that works better for you.
Flow 1: Run On Create/Update
Flow 2: Run On Delete
Please wait while flipbook is loading. For more related info, FAQs and issues please refer to DearFlip WordPress Flipbook Plugin Help documentation.
|Record-Triggered||Assignment||Variable and Collection|
Does the solution solve your problem? If not, write us what your problem is and we will build the flow for you!
Very useful! I am thinking about its implementation and use batch apex to fake update the records so the fields will be populated, I guess with batch apex governor limits will not be reached.
Thanks Jaime 🙂 For mass update the field, I would probably create another before-save flow with Get Records to run on the parent records instead of the child ones, but yes bulk apex should work as well
Very useful. However, I have a scenario like this but a slight change. How to show the latest child record name On Parent? So, If Account has 4 cases, I would like to show Case Number of only one case record that was created as latest on Account. Many cases can be created on same day for an account, so would like to pick the one as latest one.
Hello! If that’s the case, you can create a record-triggered flow on Case to update the field on Account whenever a Case is created. This would be the easiest way to achieve your requirement. Hope it helps!
I am wondering if you added a schedule path to the flow with a batch size could you avoid the governor limits? I am also stuck on the number 12 for editing Accounts more than 12 times. Is that saying something like… Bulk upload of 12 cases for one account will hit governor limits and could you assist with the math for that?
This has been a fantastic find for us but we are also operating with a managed package so we took a slightly different direction. We are using this flow example if a specific field (isChanged) of the child record along with additional criteria. We created another flow triggered from the master record, added a rollup field and used the rollup field (isChanged) for adding and removing from the resultant list.
Hi Patty, great question! Theoretically yes – one batch is executed in its own transaction thus has its own transactional limit.
I have another use case that sounds similar to your approach, but I added an additional condition so the checkbox won’t be updating again and again on the master record. You can also set up a scheduled path so the roll up calculation is done with a bit of a delay. Hope this example will help!: https://salesforce-flowsome.com/create-custom-roll-up-summary-with-flow/
This was just the very thing I was looking for! Or… at least as close to it as I could get when dealing with two custom objects. Just wanted to say thanks so much for making this so straightforward!
I am happy to hear that Yvonne! Thanks for leaving a kind comment:)
Hi Melody, thank you so much for this fantastic resource. It was exactly what I needed for a project that I was struggling with! As this flow is basically a forward-looking trigger, I’m wondering how you would go about back-filling all the existing data in the system, so that in your example ALL account records would have accurate Case Numbers fields as opposed to only those that are acted upon after you activate this flow.
Hi Melody, this has been a super useful flow and works great! One quick question however – I have an additional field added to pull in an additional field for languages, but it frequently has duplicated values (ex: Adding 3 related records and the field populates as “English, English, English”). Do you have a recommended way to de-dupe those fields so it only pulls in unique values across all the records the flow is grabbing?