How to create a simple Salesforce flow to roll up data

Salesforce flow is a powerful platform tool that can accomplish complex data manipulation in a declarative way that a Salesforce admin can maintain.

We’re going to run through how to create a simple Salesforce flow to count the number of child records and roll the count up to the parent. This is especially handy when you can’t have a master-detail relationship between your objects (i.e. if Product2 is your child object).

Scenario:

In our example of building out a new Salesforce Sales Cloud CRM system for RocketMax, we have products that can only be sold in specific postcodes. We uploaded products earlier in this tutorial. These postcodes have additional information that we’ll be using later down the track when we start to build out our CPQ quoting engine, including the number of child products each active postcode has.

Solution:

We want to create postcodes as records in a ‘Postcode’ custom object, with a lookup to this object from the Product2 table, and when the postcode status changes to ‘active’, have a flow update a ‘number of child products’ field on the postcode record. While there are a number of ways to trigger a flow, we’ll be using a process builder in this solution.

Alternative solutions:

Depending on your needs, Rollup Helper might also be something to consider, or you could use a custom apex trigger and class to modify the data. However, we want to leverage the tools the Salesforce platform gives and make our solution maintainable for a system admin, and we want our solution to be as declarative as possible, so a Salesforce flow is the best fit for our requirements.

Steps

  1. Log into the Salesforce org you signed up to earlier.
  2. Click through to the setup area
  3. Create the custom parent object you’ll be using to roll your product counts up to, making sure you have a number field that will hold the counts
  4. On your product object, create a lookup field to your new custom object
  5. In the quick find box, type in ‘Flows’, and click on the link that appears in the sidebar
  6. Click New

Leave a Reply