Skip to content

Rollup Summary Fields and Flow Action

Most Salesforce implementations require rollup summary fields at some point. However, the native rollup summary fields are limited.

iDialogue includes a rollup summary flow action that handles most common rollup use cases encountered in document and content-driven solutions, such as generating complicated quotes, orders, and invoices.

Examples of using rollup summary fields:

  • PDF Quotes with total amounts summarized by product type
  • MRR and ARR summaries
  • Account-based summaries for total active products by type, family, or product code
  • Invoice amounts. Total paid. Total outstanding.

This will appear if the image fails to load

iDialogue implementations commonly deploy lots of rollup summaries. These rollup summaries in turn are merged into document templates or used in formula fields / flow conditions to determine the presence of absence of line item types and categories.

Features:

  • Cross-object rollups. Example: Summarizing Total OrderItems on an Account record.
  • Filters can be expressed using any SOQL WHERE syntax, with up to 5 hierarchical relationships.
  • Unlimited rollup summaries per object.
  • Easily deployed from sandboxes to production as a Custom Metadata Type.

iDialogue rollup summaries are extremely versatile and flexible. As long as there is a lookup relationship between any 2 objects, then any aggregate query of child records can be stored on parent summary fields.

Implementing Rollup Summaries

There are three components to Rollup Summaries:

  1. Custom number fields on Parent objects
  2. Rollup Summary Definitions
  3. Record-Triggered Flow Actions

Summary Fields

Create custom fields on parent objects to store the rollup values. These are commonly Number or Currency fields.

Example: to summarize the total number of subscription products on an Account record,

  1. Create a new custom field with naming convention that reflect what is being summarized
  2. Use data Number or Currency
  3. Define a default value (typically this is “0”)
  4. Define the number decimal places

This will appear if the image fails to load

Rollup Summary Definition

To create a rollup summary definition, go to Setup and search for “Custom Metadata Types”. Locate the custom metadata type “Rollup Summary Definition” and click on “Manage Records”.

This will appear if the image fails to load

Create a new Rollup Summary Definition with the following properties and definitions:

  1. Rollup Label
  2. Rollup API name. Important! This is the value used when retrieving rollup summaries in flows.
  3. Execution Policy. Leave as “Synchronous” (reserved for batch processes)
  4. Define the Parent Object.
  5. Define the API field name on parent object to be updated.
  6. Define the related child record type to be summarized
  7. Child parent lookup: the field that relates child to parent object
  8. Aggregate Operation (see below for details)
  9. Child Field to Aggregate. For COUNT aggregations, use “Id”. For “SUM”
  10. Query filter. Aggregates a subset of child records based on WHERE clause.

This will appear if the image fails to load

Rollup summary actions issue a SOQL Aggregate query under the covers. So any aggregate that can be accomplished using this API is also possible with the RSA.

  • Use COUNT to summarize the total number of child records meeting filter criteria.
  • Use SUM on a currency field to get total amounts.
  • Use MIN and MAX on number, date, or date time fields to get the lowest or highest value from the collection of child records.
  • Use AVG with any number or currency field to calculate an Average value.

This will appear if the image fails to load

Flow Action

Rollup summary fields are triggered via flows. Any flow type may initiate a rollup summary re-calculation. A record-trigger flow is the most common use case. But there are a variety of use cases and applications.

This will appear if the image fails to load

  • Screen flows may invoke rollups at any point in a product configuration flow
  • Schedule-Triggered Flows are useful for nightly batch operations, or mass updating summaries on many records.
  • Autolaunched-Flows most often contain reusable process logic, and are a good option for invoking rollups.
  • Record-Triggered flows commonly initiate rollup summaries in an AFTER update context.
  • Platform Events. iDialogue implements an event-driven architecture that raises events for every customer interaction. These events can conditionally initiate a recalc of summary fields.

Update Opportunity Quote Summaries After Update

These steps describe how to update Opportunity number fields everytime a product is created or updated. The practical example might be summarizing the total number of recurring (subscription) vs one-time charges on a quote.

Start by creating a Record-Triggered Flow.

  1. Define the object that will trigger the rollup. Typically this is the child object in any parent-child rollup relationship.
  2. Best practice is to initiate the rollup calcs after create and update.
  3. To always trigger rollups, set the condition to “None”. If possible, use “Is Changed” conditions to only invoke this action when pertinent fields are changed. This will significantly improve org performance.
  4. Optimize the flow for AFTER action context. Choose the fast field BEFORE update option only in situations where other flows are waiting on real-time recalculations (such as a screen flow calling an auto-launched flow).
  5. When using the AFTER condition, then running the rollup summaries asynchronously ensures the record-trigger is not blocking.

This will appear if the image fails to load

Flow Elements

Most rollup summary flows require only one element, the “Rollup Summary Action” element. This is the only required element. The action will automatically retrieve all rollup definitions for a specific parent-child relationship and run the aggregate queries.

Flows may optionally GET a specific rollup summary definition (MDT metadata) record to be applied to the rollup.

The asynchronous branch is displayed in this diagram (see performance optimization points above). But either flow branch may execute the rollup action.

This will appear if the image fails to load

When adding an action element, search for “Rollup Summary Action” and add it to the flow.

This will appear if the image fails to load

Flow input parameters:

  1. Provide a flow label.
  2. Optionally provide a flow description.
  3. The parent record Id to be summarized (required). This is the $Record that initiated the flow.
  4. To fetch all rollup summary definitions of a particular child record type, define the object name here.
  5. To run one specific rollup summary definition, set the GET record here.

Note: Either (4) or (5) must be provided. But not both. This will appear if the image fails to load

Testing and Troubleshooting

Once the flow is activated, create or update a record and validate the rollup fields on the parent object.

If the rollup fields are not summarizing as expected, then check the following:

  • Review the rollup summary definition record. Are the object field names using the exact API name syntax? It’s useful to copy and paste field names into the definition to be certain.
  • Is the COUNT aggregation type being used? If so, verify the Child Field to Aggregate is Id (no other fields can be used in a COUNT query).
  • Is there a query filter defined? If so, use Developer Console, or any query tool to verify the query contains valid syntax (yes, a declarative tool would be useful here. It’s on the way soon! -ML )

Finally, contact support@idialogue.app with any questions if the matter is not resolved.