Cheat Sheet for Declarative Lookup Rollup Summaries
Business Problem
We have records that are related to each other in Salesforce and need to roll up values to the parent record. We tried using roll-up summary fields, but we ran into one of these issues:
-
- Our records do not have a master-detail relationship, roll-up summary fields do not work on lookup relationships.
-
- Cannot use the following in roll-up summary filters:
-
- Formula fields
- Filter logic
- Relative dates
-
- Cannot use the following in roll-up summary filters:
-
- Reached the roll up summary limit for an object.
We need a different way to automate the update to these fields easily.
We have heard about this amazing, free, open source tool called Declarative Lookup Rollup Summaries, but need a little help figuring out how to install it. The documentation can be a little intimidating for someone new to Salesforce. This article will serve as your cheat sheet to get up and running fast!
Or continue on for a short tutorial below.
Note: The video tutorial goes way more in depth.
How to Install Declarative Lookup Rollup Summaries
-
- Go to the Salesforce.org MetaDeploy link for DLRS.
-
- Documentation can be found here.
-
- Go to the Salesforce.org MetaDeploy link for DLRS.
- Click Install Declarative Lookup Rollup Summaries button
- Click Log In to Install
- Click Allow
- Click Install
- When the Installation Progress = 100% Complete, click View Org.
Now, we are ready to create our first roll-up! In our example, we want to count the number of closed won Opportunities a Contact is related to. Contacts are related to Opportunities via Opportunity Contact Role records.
- First you need to create the field that is going to hold the data. We created a number field called # Closed Won Opportunities on the Contact object.
- Go to the 9 dots -> Search for Manage -> Click Manage Lookup Rollup Summaries
- Make sure it says Create new...
-
- Enter the following information:
- Lookup Rollup Summary Name: Contact | # of Closed Won Opps
- Lookup Rollup Summary Unique Name: Contact_Number_of_Closed_Won_Opps
- Parent Object: Contact
- Child Object: OpportunityContactRole
- Relationship Field: ContactId
- Relationship Criteria (this is the where clause of the SOQL query): Opportunity.IsWon=True
- Relationship Criteria Fields:
-
- Field to Aggregate: Id
- Aggregate Operation: Count
- Aggregate Result Field: Closed_Won_Opportunities__c
- Calculation Mode: Realtime
- Calculation Sharing Mode: System
- Then click -> Save
- Enter the following information:
Make sure to leave the Active checkbox set to false if this is your first roll up on the Contact object. You will not be able to save the record if it is true because we have to deploy the trigger first.
- Click Manage Child Trigger
- Click Deploy
- Click Cancel -> I know this seems weird but if you click Remove it will uninstall the trigger. Cancel will take you back to the previous screen.
- Click Active checkbox to set it to true
- Click Save
- If you have existing records that need to be calculated click Full Calculate. If not, you are all set!
For any questions, comments, concerns – let us know in the comment section below!
We would love to hear from you!