Mix Callouts with Scheduled Flows with the Updated Launch Flow Dynamically
Many invocable actions make web callouts to endpoints via HTTP. However, Salesforce won’t allow callouts when a transaction is open. So if you want to make a callout in your flow, you need to make sure that any open transactions are closed.
The recently added Scheduled Flows feature always opens a transaction when the schedule ‘fires’, and you can’t insert actions with callouts in Scheduled Flows as a result. That means that something basic like this won’t work:
However, you can use the Launch Flow Dynamically action to work around this limitation. This flow previously was discussed here. The new version 1.2 has a boolean attribute called UseFutureLaunch that can be set to True to cause the dynamically launched flow to get ‘Future’ treatment.
When an action method gets marked as a Future method, Salesforce puts it in a different queue and does not enforce the limitation that there can be no open transactions. In exchange for this, you’re basically allowing Salesforce to delay carrying out the work until some hypothetical future point when there’s less load. In practice, I haven’t see these delays be meaningful but they should be kept in mind.
When you’re using this approach, you break things into two pieces. The callouts get put in a separate, activated autolaunched Flow:
In the Scheduled Flow, add this Load Flow Dynamically action:
…and give it the name of your activated autolaunched flow, along with any parameters you want to pass.
At the moment, the parameters have to be strings, which makes it hard to pass the records that you can get as part of the schedule trigger batch query. However, you can work around that if you need to by using Serialize and Deserialize: have the Scheduled flow serialize the retrieved record, pass it to Launch Flow Dynamically as a string input parameter, and then Deserialize it into a record.
For developers, you can learn about Future methods here.