Duplicate id error when using rollup_mdt based rollup invocable action from record triggered flow #465
-
We're currently running version 1.5.65 I recently made the change for a couple objects to no longer invoke rollups from apex trigger and instead use the Rollup__mdt-based rollup Invocable Action in a record triggered flow. We needed more flexibility in entry conditions to triggering ANY of the rollups for those objects and handling this through our existing flows is easier for us. Basically following exactly the same process as outlined here: https://github.com/jamessimone/apex-rollup/wiki/Perform-Rollup__mdt-based-rollup-Invocable. I haven't changed any of the underlying custom metadata records that define the rollups, but since using the flow action to invoke, I've been occasionally seeing the error "Row with duplicate Id at index: 2". I assume this may be due to flow bulkification and somehow multiple updates to the same record are being made (which I need to look into), added & processed together in the currentrecords and priorrecords collections I'm using in the invocable action. But I wanted to see if anyone else is running the flow mdt-based trigger instead of apex trigger to invoke custom metadata based rollups and experienced this same issue or have any tips on using this type of setup. I think that due to flows inability to de-dup bulkified record collections, maybe the rollup package should do some de-duplication before processing? I'm not sure, just know that I hadn't seen this error pop up before |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The rollup package does attempt to do de-duplication, particularly in the event that records get updated multiple times due to flow/trigger recursion. That being said, I thought I had uncovered all of the duplicate Id issues previously! If you do manage to get a log of one of the times that the happens, I would be curious to hear the full stacktrace for the error. It should be easy to fix, just need to track down where it's happening. Thank you! |
Beta Was this translation helpful? Give feedback.
-
Thank you! If I have some time and can catch one of the failures I'll send you the log details. It seems to be happening very infrequently now. |
Beta Was this translation helpful? Give feedback.
Ah, @alxman2021, I should have checked the version you reported you were using more thoroughly - this issue was actually reported to me over Discord by @fefris, and I fixed it in #448. If you upgrade to 1.5.68 (or higher), this issue will go away permanently!