CommitTransaction is a simple Flow Action that works in Screen Flows and simply causes any open DML transaction to close. This is the same thing that happens whenever a Screen element executes or when a Flow ends. Having it in the form of this action allows you to close transactions in places where you might otherwise violate limits.
Consider this Flow:
This Flow highlights the ability of the Flow Action Generate Collection Report to create attractive output out of lists of records:
Note that in order to generate this report, the set of related Contacts has to be queries for each Account. This is done in a Loop, and if the initial set of Accounts is near or over 100, you’ll get this error:
This is happening because the 100 passes through the Loop are all being aggregated into a single transaction. This makes sense in general as a system efficiency technique, but it’s not what we want here.
If we insert a CommitTransaction action into this loop, it becomes 100 individual transactions, and the flow finishes properly:
Here’s where I inserted it:
You can see this in action in the video on this post. Keep in mind that the grouping of activities into a single transaction makes slow things run more quickly, so if you place Commit Transaction into big, busy loops, it may take a lot longer than you’re used to.
How does this work?
If you look at the code, you’ll see that this action is actually an empty Local Action. Local Actions, by dint of their architecture, close open transactions.
How is this different from the ‘zero-duration Wait element’ approach?
Probably nothing. This is just a little more straightforward to implement, at least once you have it installed in your org.
Does this work in Autolaunched Flows?
Sadly, no. For those, use a Pause element and give it a time of 0 to get the transaction to close.
Version 1.0 Unmanaged 6-13-20