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
222 stars 30 forks source link

Rollup through junction object only partially working #602

Closed alxman2021 closed 4 months ago

alxman2021 commented 5 months ago

I just updated to the latest version 1.6.29 today to ensure I have the latest updates since I saw some updates related to the grandparent rollup features.

I have a use case where I'm trying to roll up an opportunity count to contacts through the standard salesforce opportunitycontactrole junction object. There will be cases where the same contact could have multiple contact roles on each opportunity, so I want to only count distinct opps in the rollup. I believe I have set up the custom metadata record properly for this use case because when I perform a full recalculation I return the correct value for my rollup. But something is off with how this is triggered and I can't figure it out.

image


Full Recalculation

Full recalculation works perfectly fine: Opp A has 2 contact roles for the same contact Opp B has 2 contact roles for that same contact

The contact rollup correctly returns a value of 2 distinct opportunities upon recalculation.


Insert/Update Scenarios

The rollup is not working upon insert or update of contact role records. Upon insert or update of contact role records, nothing happens to the contact rollup field.


Deletion Scenarios

It will work upon deletion, as long as there is one remaining opportunitycontactrole record for the opp linked to the contact.

This scenario works: Opp A has 2 contact roles for the same contact Opp B has 2 contact roles for the same contact

-I manually clear the rollup field value on contact record -I delete one of the contact roles for one of the opps

Result following the deletion: The rollup fires and correctly returns a value of 2 distinct opportunities into the contact rollup field

This scenario doesn't work: Opp A has 2 contact roles for the same contact Opp B has 1 contact roles for the same contact

-I manually clear the rollup field value on contact record -I delete the last contact role for Opp B

Result following the delete: Nothing happens to the contact record. The contact rollup field still has no value

jamessimone commented 5 months ago

I'll take a look and see what I can see - I'll let you know if I have any questions

alxman2021 commented 5 months ago

@jamessimone nevermind...don't waste your time, was me being dumb again. I thought we had opp rollups and thus the rollup trigger set up there, but I was thinking of another org apparently.... One of our devs corrected for me and seems to be working well now :)

alxman2021 commented 5 months ago

closing

alxman2021 commented 5 months ago

well at least now we have a working example here if anyone want to use this for reference!

jamessimone commented 5 months ago

@alxman2021 no worries whatsoever! Your screenshot will serve as a great reference in the event anybody else is having this issue