0

I have a sub-flow that is to be called from flow, Just want to know will the sub-flow be considered to be part of the same transaction as that of flow?

1 Answer 1

4

The sub-flow is part of the same transaction. The sub-flow is really an organizational encapsulation of logic to make flows easier to read and debug as well as promote reuse of common logic. In the old old days of programming, the sub-flow is like a subroutine.

The only aspect of Flows that start new transactions are

Plus anything the flow does that starts asynchronous transactions like:

  • Invocable apex that in turn does a @future, queueable, batchable, schedulable, or publishes a platform event
  • Publish a platform event
9
  • 1
    All invocable apex is in a separate transaction from what I have seen. But then I was looking at this in the context of apex that published a platform event, so maybe not...?
    – Phil W
    Feb 19, 2022 at 21:40
  • @PhilW invocable apex executed from a flow action is in the same transaction based on my experience. But you are making me question myself. :-)
    – cropredy
    Feb 19, 2022 at 21:47
  • 1
    Well, a publish after commit platform event requires the transaction to include at least one other DML operation. Our flow had one prior to the invocable apex call, but the platform event was never published, implying that the Apex called ran in a separate transaction. I probably need to re-test this.
    – Phil W
    Feb 19, 2022 at 22:34
  • 1
  • 1
    To be noted: new Transaction does not mean, that the new transaction got executet. If origin transaction runs into an unhandled exception also future Calls, batched or scheduled jobs are CANCELED, too! The only exemption are platform Events which are defined as "publish immediatly". these events are published although the transaction rollbacks.
    – TheShadow
    Mar 11 at 14:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .