Use Flow Builder to Create a Roll Up Summary Field

By

Roll-Up Summary fields are an incredibly useful tool in Salesforce. They allow you to create Sums, Counts, and more for objects that share a Master-Detail relationship. However, there are many object relationships that are defined by Lookup fields. A Lookup relationship is more flexible than a Master-Detail relationship, but does not inherit some of the built-in functionality of a Master-Detail relationship. You cannot use Roll-Up Summary fields to create a Sum or Count for objects related with a Lookup field, but we still often want to be able to do this!

As it turns out, you are in luck! With the powers of Flow Builder and Process Builder, you can create a Summary or Count field to populate values on objects that do not share a Master-Detail relationship.

Let’s take a look at our use case, and how to build a new Flow and a Process to populate a count field.

Below is our data model. We have a custom object called Projects. The Projects object is related to the Account object via a lookup field on the Project object. We have also added a Number field to the Account object called Project Count Total. This field is where we want to populate the total number of Project records associated with an Account record.

Once you have defined the objects you want to count, and the number field where you will store that count value, you can follow the steps in the video below to create a Roll-Up Summary field for your objects.

Now that you have covered the basics of creating a count field, where else can you use this tool? You can add additional filters to the “Get Records” element to create a filtered count to count only records that meet certain criteria. Also once this field is populated, you can use it in Dynamic Lightning Pages to filter specific components based on the value in this summary field. For example, if there are no related projects, then you could add a reminder to your users to add one.

Edited to add:

This solution does not run on record delete. This Flow is triggered by a record update or creation, so it would not recount on record delete.

Related resources:

Duplicate a Record with Lightning Flow in Spring ‘20

#AwesomeAdmin Melissa Hill Dees wondered aloud to the Trailblazer community on Twitter how she could duplicate a Salesforce record while updating some of the fields using only declarative tools. Melissa says, when a record meets a specific criteria, “I want to duplicate the record, adjust some values, and save the new record.” This made me […]

READ MORE

Scheduled Flows for the Win

An #AwesomeAdmin for a non-profit art school recently reached out to me with a problem. She adopted the school’s org a while back and has helped them make small changes over time. This #AwesomeAdmin, Sam, (real names have been changed) got a frantic email from the school’s program administrator saying that Salesforce was broken! As […]

READ MORE

10 Game-Changing Flow Solutions

Lightning Flow makes it possible to build seamless experiences for your customers and employees with as little code as possible. By applying the power of low-code, drag-and-drop functionality to customer engagement, you can automate the complex logic of your business process in Salesforce – even if you need to interact with external systems. Two builders […]

READ MORE

Have an Idea for a Story?

We are all about the community and sharing ideas.
Do you have an interesting idea or useful tip that you want to share?

SHARE YOUR IDEA