Use Flow Builder to Create a Roll Up Summary Field


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:

Learn How to Build Beginner to Advanced Flows in 3 Weeks

We’re excited to introduce #AwesomeAdmins Automate with Salesforce Flow, a brand new, three-part Trailhead LIVE series premiering this month that is all about how YOU can start automating business processes today. Over 3 weeks, we’ll focus on building beginner to advanced flows. Whether you’re just getting started with automation or you’re a #Flownatic and automation […]

Sam Reynard badge

Flow Automation with Sam Reynard

Today on the Salesforce Admins Podcast, we kick off Automation April by talking to Sam Reynard, Senior Manager of Product Management on the Flow team at Salesforce. We go over improvements coming to Flow and why it should be your one-stop shop for automations. Join us as we talk about why you should pay attention […]


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 […]