The Declarative Lookup Rollup Summaries (DLRS) managed package, referred to as “Delores” by Salesforce professionals, was created by Andrew Fawcett, CTO of FinancialForce.com to unlock additional analytical capabilities. The package is an open-source community application that is constantly improving with each new release. This powerful tool allows the declarative creation of rollup summaries between loosely-related objects with lookup relationships in Salesforce, rather than the master-detail relationship, which is typically required.
Benefits of Salesforce rollup summary fields
Salesforce rollup summary fields allow users to aggregate and summarize data across relationships. In the native version of Salesforce, rollup summary fields can calculate and display the sum, minimum, maximum, or count of a set of related detail records on a parent record. This can be useful for creating a snapshot of important information, such as total sales or the number of open cases on a parent account or opportunity record.
Reasons to use lookup relationships in Salesforce instead of master-detail:
Rollup summary fields can only calculate data from child records on the related parent record using master-detail relationships. However, to circumvent several limitations with master-detail relationships, some users will choose to relate objects with a lookup relationship in Salesforce instead. These include:
-
Sharing and Security Settings
The child object in a master-detail relationship automatically inherits the sharing and security settings of the parent object. Comparatively, lookup relationships have greater freedom for setting the sharing and security settings. -
Required Attribute
Master-detail fields are always required, so you cannot create detail records without a parent record. Lookup relationships can be variably required. You can create detail records without assigning a parent record if you do not require the lookup field. -
Cascade Delete
Master-detail relationships always cascade delete the detail records when you delete a parent record. You can set lookup relationships to cascade delete or keep detail records when you delete the parent record. -
Record Ownership
In master-detail relationships, the owner of the parent record will always be the owner of the child record. Instead, in lookup relationships, different users can own the parent record and the detail record. -
Detail Standard Object
Master-detail relationships do not allow standard objects to be on the detail side of the relationship. Lookup relationships in Salesforce do not have this limitation. -
Maximum Number of Relationships
You can create a maximum of two master-detail relationships per object. Master-detail relationships also have a depth limitation of up to four levels from the parent object and three levels of rollup summary fields. Additionally, the child of one master-detail relationship cannot be the parent of another. Further, lookup relationships allow up to 25 relationships per object and do not have the same depth or child-parent limitations. -
Maximum Number of Relationship Fields
Two objects can only have one master-detail relationship field. However, two objects can have an unlimited number of lookup relationship fields.
While master-detail relationships are necessary in some cases, there is greater flexibility and customization available for lookup relationships.
How to implement lookup relationships in Salesforce
If the reasons above have convinced you to switch any of your master-detail relationships to lookups, you can easily convert them by removing any existing rollup summary fields from the parent object and changing the data type of the field to a lookup relationship. It is also essential to review sharing and security settings after converting any fields to preserve security in the organization. The process of recreating the deleted rollup summary fields using DLRS is as follows:
-
Install DLRS into a Salesforce organization.
First, visit the DLRS installation site. Then, log in to a sandbox environment for the organization. It is very important to make any new changes in a sandbox environment to complete testing and prevent any disruptions in production. After logging in via the link above, the installation page allows the choice to install for administrators only, all users, or specific profiles. The package then installs one application, nine objects, and two permission sets that allow you to provide users access to create lookup rollup summary fields. -
Create a declarative lookup rollup summary.
First, create a lookup relationship between the objects in Salesforce if there is not already one. Next, create a number, currency, or text field to store the rollup value. Finally, navigate to the newly installed declarative lookup rollup summaries app and select the manage lookup rollup summaries tab. In the latest release of DLRS (2.17), you can create lookup rollup summaries using their new wizard. Select “Try Our New Wizard” and complete the required fields.
First, create a descriptive lookup rollup summary name and corresponding lookup rollup summary unique name. Write a description of the intended use for the lookup rollup summary. Then, select the parent object from the dropdown list and confirm. Select the corresponding child object with the new field that you created and confirm. The wizard will populate the lookup relationship field for the objects in Salesforce. Next, enter any relationship criteria in a Salesforce Object Query Language (SOQL) query form to filter the child records. The rollup summary field and the relationship criteria fields that the relationship criteria references will calculate this.
Under rollup details, select the field to aggregate from the child object and the aggregate operation (i.e., average, concatenate, concatenate distinct, count, count distinct, first, last, maximum, minimum, sum). Then, select the aggregate result field to store the results, which you created in the steps above. The wizard gives the option to aggregate all rows. This will include records that are in the recycle bin or that you move to the archive. If you set the aggregate operation as last or concatenate, you can only set a row limit to pull a specific number of records. Additionally, for the concatenate aggregate operation, a concatenate delimiter can be set to split your concatenated operation. The concatenate delimiter can be set as “,”, “|”, or BR() for a line break.
The final choices are calculation mode and calculation sharing mode. You can set calculation mode as:
- Developer, which is called from a custom coded Apex trigger
- Process builder, which does not require later deployment of the child Apex trigger
- Scheduled, which will calculate at scheduled times
- Realtime, which will calculate each time you make a change
You can set calculation sharing mode to run in system context to ignore sharing rules or user context to respect sharing rules. -
Activate DLRS.
For realtime or scheduled DLRS configurations, deploy the Apex class. Return to check the active checkbox on the DLRS detail page. For developer mode, activate the custom trigger and class, and then, activate the DLRS. For process builder, call DLRS from the process builder, and activate the DLRS.
For further information, the official documentation about DLRS can be found here, and the GitHub site can be accessed here. DLRS is a community-driven open-source tool, so there is no official support available. Any questions about DLRS can be submitted to the DLRS Community Project in Trailhead or on the DLRS GitHub Issues Page.
The professionals in Citrin Cooperman's Digital Services Practice have extensive experience helping clients implement Salesforce solutions and customize them to support their business objectives. To learn more about Salesforce and utilizing DLRS, contact your Citrin Cooperman advisor or Kay Lindburg at klindburg@citrincooperman.com.
Related Insights
All InsightsOur specialists are here to help.
Get in touch with a specialist in your industry today.