Hi everyone,
I've been wracking my brain trying to figure out the best solution to a problem I keep running into over and over. My company loves complicated rollups. Sometimes they can be accomplished by using the OOTB rollup, and sometimes not. In my scenario it is a calculation based on two aggregates that rolls up into an option set value:
Total "Green" Child Accounts / Total Child Accounts
If Total Green = 0, then Non-Customer
If Total Green > 0 and Total Green < Total, then Partial Customer
If Total Green = Total, then Full Customer
My current solution is to have a plug-in that triggers when the green field on the child account gets updated to recalculate the parent's status. However, the plug-in sandbox worker crashes, and I'm not sure why. All of my unit tests pass, so my best theory is that there are too many child records getting updated at the same time. Does anyone have any advice on how I could optimize this plug-in or change direction to make the behavior more consistent? Right now, I'm running a SQL script to identify and clean up the data discrepancies caused by the failures, but that's not sustainable.
Yes! I wasn't aware of Power Automate work queues. Thanks for the links! I think I could convert the code I've written in the plug-in to a custom API that gets called one time on delay like you've described.
One option here is to use the new Power Automate Queueing mechanism. You can write all your transactions to a queue, then have one power automate flow (on a delayed trigger - NOT the Wait Action) pull all the messages off queue and process them in bulk.
Power Automate Work Queues:
Work queues - Power Automate | Microsoft Learn
Dataverse Delayed Trigger:
Thanks all for the replies. I wasn't sure whether there was a way to delay the execution of my plug-in until the last record in a group gets updated. I still don't know the best way to approach this problem. I agree on the sentiment that the OOTB rollup doesn't cut it for most use cases, which is why I've been looking for an alternative. My calculations aren't taking too long, but I get these errors pretty frequently. There's nothing special about my logic. It's just two Linq statements that aggregate the data and then does the comparison. I was reading Microsoft's best practices and they say that we should target to have our code execute in 2 seconds. 😐
1. Power Automate with fetchXML aggregation for roll up and aggressive parallelism
2, Plugin:
3. Rollup column
4. Azure function
Yeah, plugins have a hard cap at 2 min execution time. If your logic takes that long to get through, Dataverse will just drop your plugin execution straight into the trash.
Maybe try accomplishing the same thing with Power Automate flows instead? They aren't particularly fast, but they do offer a lot or parallelization options and if you're a bit creative about parallelization and child flows, you can get a ton of calculation done in a hurry. Most importantly, they don't time out like a plugin (I think there is some cap, but it is much much bigger).
WarrenBelz
85
Most Valuable Professional
Michael E. Gernaey
65
Super User 2025 Season 1
mmbr1606
55
Super User 2025 Season 1