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.

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
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.