How To: Create Roll Up Summaries using Flow – Part 2

As promised and continuing on from my previous post on Creating Roll Up Summaries using Flow, I want to offer up one solution for recalculating Project Total Time on Delete of Time Entry records. Remember the last time? We showed how to use creations and edits of Time Entry records to calculate a rolled-up Total Time, but this didn’t take into account record being deleted. Here’s one way we can address that.

This part introduces us to some new flow features and techniques:

  1. Deleting a record
  2. Calling a Flow from a simple VisualForce page
  3. Calling an Existing Flow from within a Flow

Step 1 – New Flow

Start a new flow and drag a Screen element onto the canvas:

Screenshot 2015-02-06 12.04.15

This simple user Screen’s purpose is to warn the user they are about to delete the Time Entry record.

Here we simply add some text which is presented to the user when they hit the Delete Button. Nothing special here! (We tried removing this completely but had some issues as delete triggers a standard confirmation box, you will see when you build your own.)

Step 2 – Create Input Variables

Next we need to create a couple of Input Variables to take the following:

  1. Project record Id (Parent)
  2. Time Entry record Id (record to be deleted)

First we create the Project Id variable:


Input/Output Type should be set to Input only – this will be passed into the flow from the Visualforce page.

Last variable we need is one for Time Entry Id:


Same as with Project Id, Input/Output Type must be Input.

Step 3 – Delete the Time Entry record

Next we drag a Delete Record element onto the canvas.


This is easy to complete. In the Delete box enter the name of the Time Entry object and below that the Field we need is the Id field. Make this equal to Time Entry variable created previously.

Step 4 – Call our existing Flow which performs the Roll up summarisation

From within the Flow Designer, find and drag your previously created flow onto the canvas. (note: you need to complete the flow from our previous post and be in the same Org)


We have some simple config required here:


In the Input/Output Variable Assignments section – Inputs tab

Set Target to varProjectId and Source to {!varProjectId}

In the Input/Output Variable Assignments section – Outputs Tab


Here we basically do the same – easy!

Step 5 – Link the flow up

Now we just need to link our three elements together like this:


Don’t forget to set the starting Element as the Delete Confirmation element.

Step 6 – Create our really easy Visualforce page

This is the closest we get to coding, but it’s not really as you can cut and paste our code…

Code for our Visualforce page:

<apex:page standardController="Time_Entry__c">

<flow:interview name="Project_Roll_Up_Part_2"


<apex:param name="varProjectId" value="{!Time_Entry__c.Project__c}"/>

<apex:param name="varTimeEntryId" value="{!Time_Entry__c.Id}"/>



You can create this page using the Developer Console or any IDE (ok, too technical).

Setup > Developer Console > File > New VisualForce Page

Give it a name and copy the code in from above and save it.

The important elements in the code are:

  • Interview name – This must be the exact API name of your flow
  • Param name – This must match the exact names of your Input variables (if not set to Input, it will not work!)
  • Finish Location – This is the clever bit, it returns the user cleanly to the Project record (you can check that everything got recalculated correctly)
  • Fields in the page follow the standard Merge format – hope it’s obvious enough to follow

Step 7 – Override the standard Delete button with this new Visualforce page

Navigate to: Setup > Create > Objects > Time Entry > Buttons, Links & Actions

Find the Delete button and override with your new Visualforce page:


This will now open our new Flow on for deletes which handles now handles the actual Delete of the Time Entry record and then calls our first flow to reCalculate the Total Time.

And there you go, hope these two posts broaden your knowledge on what is capable with Flow with a little Process Builder and Visualforce to glue it all together. As always, comments very welcome.

Disclaimer Note: API deletions would not trigger a reCalculation

8 thoughts on “How To: Create Roll Up Summaries using Flow – Part 2

  • Is it possible to achieve it without using VIsualforce page?
    I don’t want to change the standard functionality

    • To cover the deletion of records in the UI, I think you’ll need this override in place. The alternative would be to use some other override, like removing the Delete button and using a ‘Delete?’ checkbox or something to fire off some Apex. But you’re still changing standard functionality that way.

      • Hello Chris, thanks a lot for this article. Really helpful!
        I think there’s a way to accomplish this without code:
        You can use a Flow Action – You must hide the “Delete” standard button and include a “Custom Delete” Flow action. This flow action will launch the “Deletion flow” and the result should be the same, I’ve just checked it and it works fine.
        The only missing aspect is that you cannot define a finish location with the flow action.
        Hope this helps.

  • Nice solution. What happens when I delete records using data loader. Will the recalc occur or is that a gap with flow?

    • That is still a gap within flow. We can handle deletions in the UI, but via the API (e.g. Data Loader) is a gap… unless you were to invoke a flow via Apex. Then the Apex can detect the delete and kick off a new flow to perform the recalc.

  • What about changing the value of the field? For instance, if someone entered the wrong field value and saved it. Then went back and update the field to the correct value.

Leave a Reply

%d bloggers like this: