Salesforce | Roll-Up Summary using Flow
What is a Roll-Up Summary field?
A roll-up summary is a field that calculates values from related records. For example, you can calculate the average number of closed opportunities, or the average amount of closed opportunities, or the SUM, MIN, MAX number.
Limitations according to Salesforce help documentation
What alternative solutions do we have?
Apex/Trigger.
You can create a method that will make all the calculations and update needed fields. If you need to make some changes or update something, you will need a developer to accomplish this task. There are many solutions that can be found in the forums.
Flow/Process Builder.
This is one of the most popular approaches. It does not work when you Delete a record, but it will recalculate the values once you add/update a record again.
Bellow you can find an example of a Roll-UP Summary field that summarizes the total amount of paid invoices for a specific account :
Step 1 : Create a custom Roll-Up Field for an Account or any other object. In my case it is Total Amount.
Step 2 : Create a custom object if you don’t have it yet and add a Look-Up field to the object. In my case I use Look Up to the Account Object.
Step 3 : Create a Flow that will Sum Up all records linked to a specific Account.
Set it up to store All Records and choose fields to store in the new variable.
You need to add Value to the previous amount.
The whole Flow diagram
Step 4 : Create a process in Process Builder. The process will be launched if we add or update any record for the Invoice custom object.
Once a record is added/updated, the process will launch the flow and pass the needed parameters to the flow. In our case, it is Account ID.
Record-Triggered Flow
This approach is similar to the previous one. The only difference is we don’t need to use Process
Builder.
Scheduled Flow.
Another possible solution that I have not tested yet is Schedule-Triggered Flow. This is a relatively new option launched by Salesforce. In this case, you don’t need to build a process in the Process Builder. You just need to create a Schedule-Triggered Flow. It can be applied by Advanced Admins.
We can create a Flow that gets all records from the Object that we need to aggregate. The Flow will store all the records in a variable – $Record global variable. The variable can be used in the Flow. In our case, I want to get all records from Invoice Object.
Once we get the variable, we can build a similar flow that we built before in this chapter. The only difference is that we need to get records from the Account object. In the Loop, we will need to add an additional Loop that will SUM all records from the $Record global variable based on the Account Id that we get from the Loop 1. All the aggregated fields should be stored in a Record Collection Variable. The Update Records should be added when the Loop 1 is finished.
Summary:
The most effective solution is still using APEX/Trigger. You can create an optimized Query and update the field. You can launch a scheduled task and aggregate the needed values. The approach will require a developer’s participation.
The Flow/Process Builder solution & Record-Triggered Flow are pretty simple solutions that require some setting up from an Administrator. They run only when you create/update a record. If you delete a record, you might see some inconsistency in the Summary field, but it will disappear once a new record is created or a record is updated. You can also Prohibit removing records and leave the options available just for an Administrator.
Scheduled Flow – can be run on a daily basis. We will go through the pros & cons of it in a separate article.
Special thanks to posting Author: Arthur Koryaka, Working for Ergonized
LinkedIn:- https://www.linkedin.com/in/arthur-koryaka/
Sharing is Caring 🙂 #KeepLearning #KeepBlazing #AwesomeAdmin
You are missing several variables and steps in this outline
Yeah. I have also noticed that but the thing is this is a guest post. Soon I will upload a video for the same and you can follow that.
I was able to build it and add to it to meet needs. Its spotty and unclear that could cause others to not like this post. A video would be great and probably better than just adding in more screenshots.
I will put the video ASAP.