0

I have a small problem with visual flow. I try to execute callout in flow through @InvocableMethod but before this callout, I do update a record(standard update action in Visual flow not in apex code(update)), and I got issues:

"You have uncommitted work pending. Please commit or rollback before calling out"

Yes I know that I can not execute DML before callout but I try to perform my DML(update) in subflow and then execute callout and I got issues too and when trying callout transfer to subflow I got issues too.

  1. Can you explain why?
  2. Flow and subflow is it different transaction?

Thanks.

2 Answers 2

0

The solution to this (and best practice for all invocable apex that does callouts is to do the callout in either an @future or Queueable). This way

  • The DML done by the flow (or subflow) + invocable invocation occurs in transaction 1
  • The callout is done in transaction 2
0

Subflows are executed in the same transaction.
To create a new transaction and complete the dml work before the callout, insert a screen or pause node.
The pause node can be configured to resume 0 hours from the current time if you need the flow to continue without human interaction.

You must log in to answer this question.

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