jamessimone / apex-rollup

Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.
MIT License
210 stars 30 forks source link

Grandparent rollup not triggering when intermediate (parent) object is reparented #518

Closed baobao917 closed 10 months ago

baobao917 commented 11 months ago

Opening up this new issue that was identified/discussed in #509 after it was fixed/closed.

In #509 I had the following question: image

Grandparent rollup relationship: ProductConsumed->Work Order->Asset.Plan_Spend__c

As stated in the screenshot, I tested this two different ways:

In neither case, did it trigger the grandparent rollup to calculate.
Please see video - https://www.loom.com/share/cb5ddf8df4694b94a16632988da40995?sid=49bb8813-8e49-4200-b0c1-8c143ceca6bb

jamessimone commented 10 months ago

@baobao917 made some progress on this issue tonight, though I still have some work to do on it. This will require the intermediate flow on Work Item - which I've activated in your sandbox. At present, the recalculation for the new grandparent is working; what I have left to do is the proper handling for the old grandparent record.

baobao917 commented 10 months ago

@jamessimone Thanks....quick question on the flow trigger on the intermediate object (work order). That particular object has lots of automations on it and we've been really careful about about overloading it b/c we've been hitting limits in the past. This is one reason we felt ApexRollup was well suited for this use case (grandparent rollup) which would bypass the intermediate object altogether.

Since we need a flow/apex trigger on the intermediate object to handle possible intermediate reparenting, I'm assuming by adding a flow trigger on the work order object that could contribute to that transaction time and possibly hit our limits again. Do you have any suggestions for us? Would making the intermediate trigger an apex trigger instead of a flow trigger significantly make a difference in performance?

jamessimone commented 10 months ago

Yeah, for Work Order in particular I totally understand that concern. Apex will always be slightly more performant than Flow, and it's possible that could end up making the difference on an automation-heavy object like that, but I was looking at a few logs generated and the Flow wasn't really adding much of anything in the way of processing time there.

jamessimone commented 10 months ago

This should be fixed in v1.6.1

baobao917 commented 10 months ago

@jamessimone Thanks! I tested and when reparenting the intermediate object to a new grandparent, the new grandparent rollup calculation was triggered.

I only noticed one follow-up and wasn't sure how you wanted me to handle or if it's part of issue #514 . The old grandparent didn't recalculate. Here's a video.

https://www.loom.com/share/7018d6cf5c6c4a209410e755ebf57e0c?sid=27fe8391-21ab-4dad-b4e8-1a0babf2a426

jamessimone commented 10 months ago

That's correct, I'll be fixing the old grandparent not updating with #514

baobao917 commented 9 months ago

@jamessimone Thanks! In v1.6.2, I tested the reparenting of an intermediate object in a grandparent rollup and the old grandparent is calculating correctly.