Declarative Rollups for Lookup Field Relationships
- Rollup information between Lookup relationships not previously possible without writing Apex Triggers
- Define rollups using standard UI declaratively, no coding required
- Define filter criteria on rollups for example Rollup Amount on Opportunity onto Account for Closed Won
- Supports Realtime, Scheduled and Developer API modes
- Open source, available in code and managed package form.
- Managed package has passed Salesforce Security Review and is Aloha enabled
- Supports Custom Metadata, rollups can be included in Change Sets and Packages for easier deployment
Please refer to the blog posts below for more detailed information.
This is a community driven tool, please help support it, share your experiences in this Chatter group.
In addition to the Wiki the tool has been featured in a number of blog entries as it has evolved...
NOTE: The links are in chronological order, if your new to the tool, read from the bottom upwards
- Declarative Rollup Summary Tool Update for v2.12
- Salesforce Rollup Summary on Lookup Relationship | DLRS Tutorial
- Monitoring your Scheduled Rollups via Report Subscriptions
- Counting Tasks with DLRS
- Getting Started With DLRS
- Refer to this for Schedule mode usage
- Declarative Rollup Tool Summer (2016) Release
- Rollups and Cross Object Formula Fields
- Packaging and Installing Rollups
- Declarative Lookup Rollup Summary Tool and Custom Metadata
- Declarative Lookup Rollup Summaries – Spring’15 Release
- A Declarative Rollup Summary Tool for Force.com Lookup Relationships
- Account Hierarchy Rollups #ClicksNotCode
- New Release: Declarative Rollup Summary Tool Community Powered!
- New Release: Spring’14 Declarative Rollup Summary Tool
- New Tool : Declarative Rollups for Lookups!
- Professional Edition. Professional Edition is supported only when using Process Builder or a Scheduled Full Recalculation. Ignore prompts to setup the Remote Site for Metadata API callouts, as this will not be needed. You can use either the new Manage Lookup Rollup Summaries tab (recommended) or the older Lookup Rollup Summaries tab. Make to select Calculation Mode as Process Builder when setting up your rollup (this will not require an Apex Trigger deployment). Please note that record deletion is not captured using Process Builder. For more information on using Process Builder with this tool see here.
- Check Existings Apex Tests. This tool dynamically deploys Apex Triggers and Apex tests, please make sure your Sandbox and Production org tests are all fully working before you attempt to use this tool. Otherwise usage of this tool will be blocked until you resolve such errors. If you have an org with triggers on the sObject that will contain the roll up result, installation into sandbox is VERY HIGHLY recommended so that after Lookup Rollup Summary records are added/enabled, you should rerun all testmethods to ensure nothing has broken as your before/after update triggers on the parent sObject will re-execute.
- Existing Tests on Parent Objects. This tool will update the indicated fields on your Parent objects when it senses activity on Child objects. Ensure an Apex Triggers you have written on your Parent objects are written with best practices around bulkification in mind. If in doubt be sure to perform significant testing.
Usage Information and Known Issues
- Platform SOQL Limits. This tool uses SOQL Aggregate queries and is subject to platform limitations. This basically means...
- Deployment issues into Production. This tool dynamically deploys a small trigger and test class to the org. This is subject to the same rules and compliances as as a regular human developer. The generate test class, can in some cases be to simplisitc to get code coverage, requiring at present a developer to assist with the deployment, especially to production. There is more details on how to look for this scenario and how to workaround it, as well as future thoughts here.
- Volume Considerations. For each rollup, there is a maximum of 50,000 child relation records that can be summarised each time child record/s insert/update/delete operations are made (which may process several configured rollups). The rollup processes children to rollup by their parent record relationship and an optional further filter if provided. Meaning so long as this relationship does not result in more than 50,000 child records per parent parent record it will be successful. Take a look at this blog post which describes some new configuration settings (see bottom of blog post) to help calibrate the tool when running the Scheduled or Calculate jobs to help work within the 50,000 row limit.
- Indexing Fields. For performance reasons ensure the fields used are indexed (lookups are by default) and also any fields used in the filter criteria. This can be very important as without this, a full table scan will occur when the platform executes the SOQL and cause performance issues. For more information from Salesforce please see here and here.
- Realtime Mode and Formula Fields. When using the Realtime mode, certain Formula field expressions need more consideration. If your formula field refereces other fields defined on the object the formula field is defined on, please state the fields these formulas reference in the Realtionship Field Criteria fields (the tool does not monitor changes in formula fields). If your formulas reference fields on related records (via lookup fields) see this blog. If your formula field uses formula functions that are date sensitive like YEAR the tool will not auto recacluate in realtime (as no field has changed). To work around this, either switch to Scheduled mode or in Relatime mode use a Workflow Field Update to copy the formula field value to a physical field and reference that.
- Sandbox Testing. While the tool can be installed and enabled directly in production, sandbox testing is still strongly recommended.
- INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor=. This can occur when your using the Manage Child Trigger button or editing rollups via the Manage Lookup Rollup Summaries tab. Solution is to disable the 'Lock sessions to the IP address from which they they originated.' setting under Session Settings under Setup. Salesforce documentation notes the following 'This option can inhibit various applications and mobile devices.'. Note this issue only applies while configuration changes are being made with the tool, especially via the Manage Lookup Rollup Summaries (see release notes v2.0). Once rollups are configured this issue does not apply during rollup calculations.
- Schedule Mode Setup. This is not so much a know issue, but a known source of confusion with the current tool. If you want to use the schedule mode features please read this first
Please feel free to raise feedback and issues via the Github Issues page here.
Packaged Release History
You can install a packaged version of the tool into your production org (sandbox testing as always recommended). Check the limatations and known issues above first!
Latest Release Version 2.12
- Enhancement - Avoid need for Remote Site setup
- Enhancement - Cannot disable DLRS in Apex
- Enhancement - Update API version of DLRS
- Enhancement - New "Lookup Rollup Summaries Tools" tab
- Enhancement - Improved UI messaging to direct users to the Manage Lookup Rollup Summaries tab
- Enhancement - Minor tweeks to the messaging on the full recalc UI's
- Enhancement - Route various apex job errors to scheduling/running users email
- Enhancement - Modify test code for parent object
- Enhancement - Avoid Shadow Custom Object Based Rollup Records - Total DLRS Newbie frustration
- Bug - Master branch has Apex Unit test failures
- Bug - Clicking Cancel on Full Calculate schedule page goes back to wrong page
Release Version 2.11.1
IMPORTANT NOTE: The Cases DLRS Trigger will fail in Summer '19 if you do not upgrade to 2.11.1 until the related known issue is fixed by Salesforce. This only impacts users with the Case object DLRS Child Trigger created and active.
Release Version 2.11
- Enhancement OR clause in top level filter breaks SOQL query
- Enhancement Upgrade to Latest API: New object are not available
- Bug SObject type does not allow locking rows
- Enhancement Remote Settings update
- Enhancement Lightning Enterprise Edition
Release Version 2.10
- Enhancement Enhancement: Schedule calculate - don't DML update record if rollup value unchanged
- Enhancement Known ordering for RollupCalculateJob records
- Enhancement Can't aggregate Salesforce Files (ContentDocumentLink) as child object
- Enhancement Reinstate support for Test Code field on Rollups using Custom Metadata
- Bug Error When Adding a Note in SF Lightning Due to DLRS Trigger
- Bug Calculate new roll up failing on "The rollup must be Active before you can run a Calculate job"
UPGRADE NOTE: If you access the Rollup definitions via the standard Salesforce Custom Metadata UI under the Setup menu. Make sure to remove 'Test Code (Depricated)' (small one) from the layout and add the new 'Test Code' field (large one). If you only ever use the Manage Rollup Summaries tab you do not need to worry about this. Also note that any test code placed in the original smaller field will be automatically migrated to the new field on next edit (via Manage Rollup Summaries tab).
Release Version 2.9
- Enhancement Support API 37.0 onwards objects. Update RollupController.cls to remove hard-coded API version references
- Enhancement Update to new fflib and optimised selector code
- Enhancement Enhancement - Button on the Summary Logs List View for deleting Logs
- Enhancement Support for Currency Roll Ups with Community Portal Users
- Enhancement Improve error message Lookup Rollup Summary 'X' is invalid, your org configuration may have changed
- Bug Support WorkOrder. Deploy Trigger. Entity is not API accessible.
- Bug Support AccountContactRelation. Deploy Trigger. Entity is not api accessible
- Bug RollupServiceTestTrigger, RollupServiceTest4Trigger and RollupServiceTest5Trigger has not been deployed
- Bug Support CaseComment Rollups, Cannot locate Apex Type for ID CaseComment
- Please check your Rollup Calculate Job records and if needed (no jobs are actually running) delete them.
- There is a new Delete Log button on the Summary Logs List View layout please add it
Release Version 2.8
- Bug Lookup Rollup Calculate Job records are not being deleted even after the Calculate Job finishes
- Bug Help Text for Calculation Mode needs updating
- Bug Account Trigger->Decimal to Integer Illegal Assignment
- Enhancement Feature Request - the ability to set schedule dlrs job name
- Enhancement Better messaging when scheduling jobs
IMPORTANT NOTE: Please check your Rollup Calculate Job records and if needed delete them.
Release Version 2.7
Release Version 2.6
- Bug DLRS fails rollup on Checkbox when no records found Thanks Wes Weingartner!
- Bug Developer Script Exception : Entity is not api accessible
- Bug Lookup Rollup Calculate Jobs not Case-sensitive
Release Version 2.5
- Bug After Delete trigger for merging fails when new dlrs added
- Bug Should not need to mark Active to do a manual Calculation
- Bug Apex Scheduler Day of Week Drop down is a day out
- Bug Merging lead causes Permission to create dlrs__LookupRollupSummary__c error
- Enhancement Support ContentNote rollups (upgraded to API 37.0)
Release Version 2.4.2
Release Version 2.4.1
Documentation: See Declarative Rollup Tool Summer (2016) Release
- Bug Installation Issue - The user license doesn't allow the permission: Read All dlrs__LookupRollupCalculateJob__c
- Enhancement Roll Up just for few number of records
- Enhancement Support for rollups on Account when doing Merge Account
- Enhancement Add support for ALL ROWS
- Enhancement Scheduled Calculate Custom Settings
- Enhancement Open Activities still associated to the Converted Lead
- Enhancement Remove from Lookup Rollup Summary Schedule Items when Parent is deleted
- Bug Attempt to de-reference a null object from RollupJob (as seen on Apex Jobs page)
- Bug SP(), BR(), TB() not working in 2.2
- Bug Calculation Id not populating in Version 2.1
- Bug Validation Errors 'ENTITY_IS_DELETED' While Saving when Parent gets Deleted As Well
- Bug multiple criteria fields don't work anymore.
- Enhancement Add support for space & tab in concat delimiter thanks to jondavis9898
- Enhancement Multiple BR() for Concatenate
- Enhancement Support for Custom Metadata (Pilot). See Declarative Lookup Rollup Summary Tool and Custom Metadata for more information.
UPGRADE NOTE: There is a new Manage Lookup Rollup Summaries tab to support Custom Metadata support.
Known Current Limitiations of Custom Metadata Support
- Ability to override the generated Apex Test code is not supported (due to platform restriction)
- Aesthetic case adjustment for object field API names will not be performed, e.g. account would not change to Account
- When you Undeploy via Manage Child Triggers button, Active Custom Metadata based rollups are not automatically deactivated, please deactivate manually via unticking the Active checkbox.
- Advanced Rollup UI is not currently available, this will be integrated at a later date
- Description field is limited to only 255 characters (due to platform restriction)
- List View support is available under Setup, Custom Metadata Types, Manage Records but does not invoke the new UI for editing
- Enhancement Allow First/Last Summaries to work on Id and Reference Fields thanks to Christian Carter.
- Enhancement Nightly Scheduled RollupJob running, but Summaries not updating, thanks to frontendloader.
UPDATE NOTE: There is a new Schedule Calculate button to add to the object Layout, see screenshots below.
This will show the following UI related to the enhancement above.
- Bug fix Rollup not recalculated when order by field changes
- Bug fix Concatenation Rollups order maybe none Deterministic - Consider moving order by from LREngine.RollupSummaryField to LREngine.Context
- Enhancement Enhance Order by to allow multiple fields and specify ASC/DESC
IMPORTANT NOTE: This release improves the query optimisation within the tool when there are multiple rollups. There is also a small change in behaviour from previous releases, relating to default ordering. If you have been using concat, first or last operations and have not specified explicit order by on the rollup, you must do from now on, it no longer defaults to the field to rollup. In prior releases the behaviour of this operation may or may not have been consistantly working as expected, depending on the existance of one or more rollups.
- Enhancement for Add developer API to mirror triggerHandler behavior
- Enhancement for Advanced Rollup API Reqiurement: Count of Child on Parent, Child Re-parent, Old Parent Count not Correct
- Bug fix for Reduced number of queries when object name case differs across rollups : Multiple LRE Contexts when rollup definition only differs by case
- Bug fix for Master records updated when related records have not changed
- Bug fix for Different order by on same relationship field results in incorrect result
- Bug fix for Rollup Summary validations not being enforced on updates after fflib upgrade
- Enhancement for Ability to enable SeeAllData in the generated tests
- Bug fix for Error with multi-currency
- Bug fix for Some of the new fields in the last release are not in the Manage Rollup Permission Set
If you are upgrading, you will need to make the following changes to the Layout.
- Add Test Code See All Data field to the layout
- Enhancement for Can't get Apex Trigger to Deploy in Production
- Enhancement for Implement the new test level features in Summer 15 to deploy triggers faster
- Enhancement for Allow users to edit child records without needing access to Rollup Summary object
- Fix for First error: Invalid Id when in Scheduled Mode
- Fix for Duplicate Field Selected error message
If you are upgrading, you will need to make the following changes to the Layout.
- Add Test Code field to the layout
- Enhancement for Private Objects / Sharing Rule
- Enhancement for Allow Master Records To Be Filtered During Calculate thanks to Christian G. Warden
- Fix for Some tests have hard-coded namespace thanks to Christian G. Warden
- Fix for Rollup fails when child field is Multi-select picklist and is null thanks to Daniel Hoechst
If you are upgrading, you will need to make the following changes to the Layout.
- Add Calculation Sharing Mode field to the layout
- Fix for Concatenate Distinct Duplicates Values When Rolling up Multi-Select Picklists
- Enhancement for Improve trigger test deployment failure reporting when Code coverage error received
- Fix for Currency Fields in the Rollup causing the issues - "Master and detail fields must be the same field type (or text based) for First or Last operations"
Read more about this releae here.
- Debug added for bug Unable to connect to the Salesforce Metadata API
- Enhancement How to rollup count of unique values
- Enhancement Rollup picklist or text values?
- Enhancement Filter by last create date
- Enhancement Support for Lightning Process Builder
If you are upgrading, you will need to make the following changes to the Layout and Picklists.
- Add Lookup Rollup Summary Unique Name, Concatenate Delimiter, Field to Order By fields to the layout
- Add Count Distinct, Concatenate, Concatenate Distinct, First and Last picklist items to Aggregate Operation
- Add Process Builder picklist item to Calculation Mode
- Fix for Exception when saving a new rollup when the child object is invalid
- Enhancement for Validate the Rollup Criteria on Save
- Enhancement for Suggestion: Add 'Description' field to Lookup Rollup Summary SObject (requires manually adding to Layout for upgrades)
- Fix for Null object error - Aggregating null currency field on child also same fix for System.NullPointerException: Attempt to de-reference a null object - Error - Post v1.14 Upgrade
- Fix for Salesforce Standard Order object OpportunityID field not recognized
- Upgrade to API 32 (sees new Standard objects) related to attempted fix for Error "Object does not exist" for CombinedAttachment
- Fix for RollupJob error: Cannot have more than 10 chunks in a single operation, thanks to David Carter.
- Fix for Two rules using same set of RelationshipCriteria fields don't create scheduled items
- Fix for System.NullPointerException: Attempt to de-reference a null object when saving a Rule
- Fix for Install error Version 1.12 - Requires Streaming API
- Fix for Support installation without having to have Ideas enabled
- Fix for Enable count rollup on any field
- Fix for Only one rollup per field working at a time
- Fix for Multiple rollups on same field fail to execute
- Fix for Apex Error Query Exception
KNOWN ISSUE: Apex Error Query Exception, please use version v1.11 below if you encounter this issue.
- Fix for Currency Conversion?, special thanks to Anthony Heber for submitting the enhancement to LREngine to fix this. The result of the child aggregation is converted to the parent record currency if the child field being aggregated is a Currency type and the org is using Multi-Currency. Note currently dated exchanged rates (available through Advanced Mulit-Currency) are currently not supported.
- Enhancement for Issue 52 Auto Create Remote Site Setting
- Fix for Issue 25 Error with Manage Child Trigger button for very long object names
Version 1.9 - Community Powered!
Read more about this release here
- Fix for Issue 23
- Fix for Issue 22
- Fix for Issue 21
- Enhancement for Issue 16
- Enhancement for Issue 5
- Enhancement for Issue 15
KNOWN INSTALL ISSUE There appears to be an install issue identified when installing into orgs without Ideas installed for v1.9, if you encourter this enable Ideas if you can, otherwise use v1.7 until the issue is resolved.
- Fix for Issue 14, relating to null pointer exception
Version 1.6 - Spring'14 Release - 9th February 2014
- Enhancements to support Schedule mode, Calculate historic records, Developer API and more, see here.
- Fix for Issue 10
- Fix for Issue 11
- Fix for Issue 3, relating to issue when deleting last child record not updating rollup fields to 0.
- Fix for Issue 2, relating to error 'purgeOnDelete option can only be used on a non-active org'
- Support for Realtime calculations
- Validation of valid fields and field types on Declarative Rollup definition fields
- Optimisation during update of child records to only apply rollup when field to aggregate changes
- More extensive unit tests, also those around use of limits such as queries, rows etc.
Version Beta 6
- Support for Realtime calculations
- Limited validation on Declarative Rollup definition fields
- Limited testing on multiple lookups
- Fixed issue with multiple lookups
Installing the Source Code (Developers)
This project now uses Salesforce DX for development and packaging. Clone this org and deploy the code to a scratch org to develop and contribute back changes via Pull Requests. If you want to deploy the unmanaged version of this to your sandbox or production org you can use the Salesforce DX convert and deploy commands to do so. However the recommended deployment for these orgs is via the managed package links above.