declarative-lookup-rollup-summaries
declarative-lookup-rollup-summaries copied to clipboard
Perform multiple calculations and updates in one rollup DML for same child/parent relationship
A common use case for nonprofits is rolling up a suite of stats from a child to parent (Most Recent x, Largest/Highest x, Average x, First/Start Date, End Date, etc). This requires building multiple rollups with same child/parent and running concurrent DMLs or creating frustrating fussy schedules to update a lot of fields on one record at a time.
If a single rollup could update many stats fields, each with their own query & calc parameters (or maybe even apply a similar sort order, child rec query across all), that would decrease build time, automation and/or nightly batching and conflicts, especially with NPSP.
If I were updating such data in code, I'd do one DML; it's the user-facing interface that mandates the one DML per stat, really. If we could make the wizard more amenable to the best way to run it in code, that would be a win.
The other option is a better CLONE feature in the wizardUX (vs going to CMDT), but that doesn't solve the multiple DML and scheduling issues. Thanks!
@barbarachristensen DLRS has always had logic to combine rollup calculations that meet a certain similarity. If you define multiple rollups then it will merge where it can (certain types of rollups that share Relationship Criteria and Sort Order are the first criteria that come to mind). I think the variety of options available for rollups now means that combining is less viable but the code should still do it when possible.
I don't remember the conditions off the top of my head but I could try and find some time to look into it if you're not seeing it happen as expected.
Regardless of the ability to merge for calculation I believe the DML to a single parent should be merged. When we see multiple DML actions caused by DLRS it is usually caused by rolling up to the parent, which in itself is a child of another rollup config.
Would you be able to provide some better examples of when you're not seeing DML combined for Realtime rollups or scheduled rollups? When are you having to manually manage the different rollups to get the results that you want.
It could be that I simply don't do the same things you do and don't realize some of the problems you're facing. Appreciate the insight where you can clarify.