As an architect, you see common recurring needs. One such need is aggregating information from child records onto a parent record. For example, how many closed opportunities does an account have or when was the last opportunity closed on this account.
In Salesforce, aggregating information from child records onto parent records is done in different ways. If the child object has a master-detail to the parent, one or more rollup summary fields can be created on the parent object. A rollup summary could be used to count how many closed opportunities an account has, for example.
An object in Salesforce can also have a lookup field, which is similar to a nullable foreign key in a table in a database. Rollup summary fields can only be created on master-details but not on lookup fields. One solution to aggregate child information linked via a lookup is to create a trigger on the child object that runs whenever a record is inserted, updated, or deleted to aggregate the information onto the parent record(s).
Declarative Lookup Rollup Summary
The better solution is to use the Declarative Lookup Rollup Summary Tool. This tool is an open source project started by Andy Fawcett that allows one to create lookup rollup summaries that run in real-time, on demand, on a schedule, or via custom code. Since it’s configured through declarative, point-n-click means, it’s much easier to manage.
Benefits
- Free managed package. Andy created this as a managed package on the AppExchange that is installed and upgraded for free.
- Implementation is quicker. Data can now be aggregated in minutes instead of the hours it takes to code, write test code, and deploy.
- More rollup options. One can rollup more than just a count, a min or a max such as the latest or earliest date or a given piece of text.
- Well Supported. With open source software, it’s important to ensure that the project is regularly maintained so bugs and enhancements are implemented. Andy and the other contributors are very responsive to the community and provide regular updates.
- Good Documentation. The documentation allows one to come up to speed quickly with how features work.
Considerations
Here are the biggest considerations I’ve run into with the tool. For more, see the GitHub project.
- Limits, Limits, Limits. Since this is a native Force.com application, it’s subject to Salesforce limits. For example, be mindful of how many records are being queried. At the time of this writing, 50,000 records can be queried in a given execution context. Also, don’t forget that the records in count() are included in that limit. See SOQL: 50,000 RECORD LIMIT APPLIES WITH COUNT() for more information.
- The tool creates a trigger on objects along with a corresponding test class for the trigger. The test class simply tries to instantiate the record and insert it. Sometimes there are custom validation rules that prevent the insertion and cause the test to fail and ultimately prevents the trigger and test class from being deployed into the org. Sometimes a developer has to create custom test code for the trigger.
What other benefits and consideration do you have? What other open source or free Salesforce tools do you use in your projects?
Luke