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 upon a child update #509

Closed baobao917 closed 11 months ago

baobao917 commented 11 months ago

I am having issues getting a grandparent rollup to work. Specifically, upon a child record update, it is not triggering the rollup calculation to the grandparent.

Please see video: https://www.loom.com/share/2d3d171e1b90429e80df32ce469f4e03

I have tested the CMDT configuration using the Recalculate Rollups button and it works when using that. So it appears that the CMDT rollup record is configured correctly. image

I am trying to rollup from ProductConsumed > WorkOrder > Asset.Plan_Spend__c WorkOrder/ProductConsumed is master-detail relationship WorkOrder/Asset is simple lookup relationship. I have flow AFTER UPSERT and BEFORE DELETE flow triggers on the ProductConsumed object using the invocable action.

baobao917 commented 11 months ago

In the Perform Rollup__mdt-based rollup Invocable Action section, it doesn't make mention of the Grandparent Relationship Field Path, but I tried the flow config with that as well. Still did not work.

image

Also tested a standard parent-child rollup and that worked as expected.

jamessimone commented 11 months ago

You shouldn't need to set the grandparent path using that flow action - that's only if you were looking to override the value you're already supplying via CMDT. Let me take a look at the recording you made and see if there's anything about the setup that needs to be changed.

baobao917 commented 11 months ago

You shouldn't need to set the grandparent path using that flow action - that's only if you were looking to override the value you're already supplying via CMDT. Let me take a look at the recording you made and see if there's anything about the setup that needs to be changed.

Sure....I've tried it every which way I can think of. For some reason, nothing is getting triggered at all. I don't see the expected RollupAsyncProcessor apex class fire in the apex jobs

jamessimone commented 11 months ago

What's the flow context you're passing in to the after insert/update action? It's just UPSERT, right? I didn't get the chance to review the video before shutting down earlier, apologies - I will definitely be able to take a look tomorrow.

baobao917 commented 11 months ago

Yes it was UPSERT

baobao917 commented 11 months ago

@jamessimone To aid you, I recorded another demo video where I step you through everything which includes more detail than my 1st video. Excuse the audio...not sure what happened.

https://www.loom.com/share/f5269740a70f461a8ff3431b63650616?sid=7d46b1ea-3b22-4183-8a18-a087045b4a87

jamessimone commented 11 months ago

@baobao917 thanks again for the great videos you record! You don't seem to be doing anything wrong (which I think we can both agree is further evidenced by the fact that the recalc button works!); there must be something wrong in the synchronous part of the rollup that is failing to trigger the async calculation piece. When you update the record, that part of the log may have enough info to go off of in fixing this - any chance you can attach one of those?

baobao917 commented 11 months ago

@jamessimone Yes I can send you logs. In this org I don't have nebula logger installed so I hope that is alright.

baobao917 commented 11 months ago

@jamessimone Here is the logs along with a video of me performing the debug. apex-07L7e00001RG1vPEAT.log apex-07L7e00001RG1vOEAT.log

https://www.loom.com/share/b8c0f6b077a8433da33278008df34b27?sid=be8db0de-ed0d-4edc-b34d-bfe95624d029

image

jamessimone commented 11 months ago

@baobao917 thanks for the additional issue. I was able to identify the issue here and I'll have the fix for this as part of the next package version!

baobao917 commented 11 months ago

@jamessimone The fix in v1.5.88 resolved the issue. Grandparent rollup is now working!

I did want to follow-up with a question I had earlier

jamessimone commented 11 months ago

@baobao917 This might be a good thing to test out, as I'm not actually sure. If reparenting a Work Order correctly updates the Product Consumed children records out of the box (which would in turn correctly call Apex Rollup), you won't need the intermediate trigger.

baobao917 commented 11 months ago

@jamessimone I tested as you suggested and regardless of whether I have an intermediate trigger or not, it doesn't trigger the rollup calculation when I reparent. Below is a video.

https://www.loom.com/share/cb5ddf8df4694b94a16632988da40995?sid=49bb8813-8e49-4200-b0c1-8c143ceca6bb

Should I open a new issue?

jamessimone commented 10 months ago

@baobao917 my plan is to tackle this and #514 in the next release