I am using Salesforce Lightning mode and looking to use the configure not code approach.

I have an external service defined.

The scenario I am trying to implment is as follows:

  1. User Creates Contact in Salesforce
  2. Automatically invoke external web service with some data from the new Contact
  3. Retrieve relevant data from external service response
  4. Update the new contact with the data

My first attempt was to create a Record-Triggered Flow that was activated when a new Contact entity was created. The flow was then able to assign relevant variables before triggering an Action which invoked my external service.

The problem I had with this is that the error "'You have uncommitted work pending. Please commit or rollback before calling out' error" appeared which led me to this article: https://help.salesforce.com/articleView?id=000328873&type=1&mode=1

So the problem as I understood it was that I cannot invoke an external service in a flow that is triggered by a contact creation.

So then I looked at creating a Process which would invoke a Flow. The process is one that starts "When a record changes" and that record is set to be a Contact record that is created. The process then is supposed to call my Flow which will do the actual external service invocation.

But I still get the same issue with the "'You have uncommitted work pending.'" message.

Even if I change the invocation of the Flow from the Process via a scheduled action I get the same error.

Any thoughts on how I should be doing this?


2 Answers 2


The reason you're seeing the message "You have uncommitted work pending. Please commit or rollback before calling out" is because Salesforce does not allow HTTP callouts during a record change process. If you were able to make callouts during record changes, database performance would be severely impacted, and record lock errors would become more frequent.

When it comes to external callouts as part of record-invoked automated processes, your best bet is to utilize a @future method. These methods will run asynchronously after the record update is complete. In your @future method, you can send the payload to your external service, process the result, and update the relevant records in Salesforce.

  • As an aside, the scheduled action doesn't work for the same reason. Even though you're scheduling the process for some point in the future, you're not separating the database transaction and the HTTP callout, which is what we can do with a @future method.
  • given OP is using Process builder or Lightning Flow, such automation should call an invocable apex that in turn does the async future or queueable.
    – cropredy
    Oct 16, 2020 at 2:54
  • @EvanSteeleSFDC thank you for your comment. I get the premise of your answer, but am using Configure not Code so am unable to define the future method. Please see my follow up comment for more detail on what I have managed. Oct 16, 2020 at 10:45
  • @cropredy thank you, I am not sure how to do that though. Please see next comment Oct 16, 2020 at 10:46
  • Having now read the last paragraph in help.salesforce.com/… as suggested by @identigral I have added a Pause to my flow which appears to do what you have suggested and allows the HTTPS request to be fired outside of the record change process. In FlowBuilder the pause option is not available in a Record Triggered flow, only in an AutoLaunched Flow, so I am still having to use a process to trigger the Flow which seams strange. Ideally I would just have the RecordTriggered flow. Oct 16, 2020 at 10:52

Consider you have implemented record trigger flow on contact creation, and you have to call any external system using callout then you have to use asynchronous branch of flow. It will allow you to perform callout. ( it will commit the contact record in db and initiate separate transactions)

Note: As we are performing callout asynchronously it will be treated as separate transaction.

Basic fundamental is we can not perform DML operations prior to external callout directly. In order to do it always use asynch apex (preferably future method)

You must log in to answer this question.

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