SFDO-Community/declarative-lookup-rollup-summaries

Support for rollups on Account when doing Merge Account

afawcett opened this issue · 8 comments

As per discussion on Chatter....

"I was testing this out by counting attachments on accounts which worked well. My question is if there is a way to trigger a recalculation upon merge? I have a lot of accounts that get merged daily, but the count didn't update after I did a test merge."

"HI @ben Patterson (Pentair Aquatic Systems) I seem to recall a help document that says that merge operations don't fire triggers. Here is the article: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_merge_statements.htm. It seems that a before delete or after delete action would fire the trigger, but I'm not sure how @andrew Fawcett (FinancialForce.com) has the triggers set up in Declarative Lookup Rollup Summaries Tool (e.g., can the tool capture a before delete action)."

"Hmm, it says no triggers for the related records are fired. That being said, we might be stuck."

"Thanks @[Kent Manning] yeah was just reading that as well, i think though this applies in the context of DLRS to the Parent object, where there is not a Apex Trigger deployed, thats only on the child. I'd need to do some testing to see whats going on here, as reparenting child records should work, i'm wondering if Salesforce is not firing the Apex Trigger on the child in this case of merge, i have some vague recollection this might be the case. Thats not to say we are dead in the water here, i'm up for considering updating the tool to deploy a trigger on the parent to support merge."

Update: I have reproduced this in an Apex Unit test and am looking at a way to resolve.

Just curious if there has been any progress on this - we're running into issues with several fields being out of date due to merges.

Nothing as yet sorry @jongpie. It is marked as a priority enhancement, so when i or another contributor gets a burst of time it will get seen ahead of others.

Ok started to explore this... its not going to be possible to get this to work realtime...

SELF_REFERENCE_FROM_TRIGGER, Object 001b000003O8CFqAAN is currently in a merge operation, therefore a trigger can not update it

Going to try this with Schedule Mode rollups...

Ok, i think i have found a solution that allows the rollup to remain realtime most of the time, and switch dynamically to schedule mode in a merge scenario. This will require the RollupJob class to be scheduled, even if you don't have any Scheduled rollups.

Added in v2.4.1.

I'm running into this issue. We selected the "allow merging" box when we created it.

Here is a screenshot of the trigger that I'm pretty sure is causing the error (only one we've added/updated before getting the error):

Screen Shot 2020-02-07 at 10 51 19 AM

@ChristiHarris can you please open a new issue and fill in the steps to reproduce etc. I am not quite sure from the above what it is you are saying is related to this issue and I think its best to start afresh. Thank you! 👍