The purpose of this blog post is to detail the benefits of using the Declarative Lookup Rollup Summaries (DLRS) managed package in your Salesforce org.
The purpose of this blog post is to detail the benefits of using the Declarative Lookup Rollup Summaries (DLRS) managed package in your Salesforce org, while also introducing the reader to some important Salesforce concepts. You will gain a high level overview about the problems that Declarative Lookup Rollup Summaries can solve, the Salesforce AppExchange, execute anonymous in the Developer Console, the Schema Builder, what managed packages are, the different types of Salesforce object relationships, the Workbench tool and the Salesforce IdeaExchange. The type of reader who would gain the most benefit from this guide is a Salesforce admin who is interested in more advanced admin and beginner Apex code. It is also useful to someone quite new to Salesforce who would like to gain a high level overview of different Salesforce concepts.
What Are Rollup Summary Fields?
A rollup summary field displays the sum, minimum, or maximum value of a field in a related list or the record count of all records listed in a related list.
For example, if you want to display the number of opportunities that each account has, you can achieve this with a rollup summary field on the Account object. Similarly, if you want to display the sum of all the opportunity amounts per account, a rollup summary field can be used to accomplish this. Rollup summary fields are very helpful because they give high level information that you might need. They can be referenced in reports and dashboards, too.
Rollup summary fields are re-calculated whenever a value has been changed for a field on the child object that is being aggregated. There is a soft limit of 25 rollup summary fields per object but that can be increased to 40, as per this Salesforce article. It is not recommended to go beyond 25, as the more rollup summary fields you create, the more complex the org can become. For example, if you have some apex code that references rollup summary fields, you may experience lock row errors.
Rollup Summary Field Limitations
One of the key considerations for rollup summary fields is that they only work on objects that have a Master – Detail relationship. For example, there exists a de-facto Master – Detail relationship between Account and Opportunity* hence, one can create rollup summary fields in this use case on the parent (account) object. Because of this, rollup summary fields won’t work on objects that share a lookup relationship.
*A further point on this: although if you navigate to Setup | Schema Builder and select ‘Account’ and ‘Opportunity’ you would see a lookup relationship, the relationship between Account and Opportunity actually acts as a Master – Detail one. For example, if an account is deleted then all of the related opportunities will also be deleted. The Account and Opportunity relationship is a special one and the uniqueness of it is emphasised more in this answer on Salesforce StackExchange; which is a great resource for Salesforce related questions and answers.
This is a frustration for many Salesforce customers. In fact, on the Salesforce IdeaExchange, this idea to have rollup summary fields work between objects that share a lookup relationship has over 16,000 points!
The Salesforce IdeaExchange
The Salesforce IdeaExchange is where Salesforce customers can post suggestions to improve the platform. One of the ways in which Salesforce prioritises enhancements and new features is based on the number of votes for a particular idea and, since 16,000 up votes is very significant, hopefully Salesforce look at this idea fairly soon.
However, until then, the Declarative Lookup Rollup Summaries solution can be used to not only do roll ups on lookups but also can be used to perform more advanced calculations on master-detail relationships than the standard rollup summary fields.
Rollup Helper
Before we go into DLRS in more detail, it’s worth pointing out that there is another app solution that can be used called ‘Rollup Helper’. As you can see from its AppExchange reviews, it is a highly rated solution but one of the downsides is that the free version only works for 3 different relationships whereas there isn’t a limit with DLRS.
Salesforce AppExchange
The Salesforce AppExchange is essentially the Salesforce version of the Apple App Store. All apps that are hosted on the Salesforce AppExchange have gone through a comprehensive security check by Salesforce. The Salesforce AppExchange is oftentimes a first port of call for trying to answer a ‘should we build it or buy it’ question. For example, one could of course develop Apex code to do calculations between lookup relationships however, there are a number of factors to consider (developer resources, code maintainability and technical debt etc) that, generally, tends to favour leveraging an app if possible as a more lower cost, quicker solution.
Apps that you install from the Salesforce AppExchange will generally be managed packages – this means that you won’t be able to see the source code and that the meta-data from these packages don’t contribute towards your Salesforce limits. You will learn more about this later in this guide.