Flow is the most powerful automation tool of Salesforce and it gives the admins the powers of developers. It is possible to manipulate data in a variety of ways, schedule the automations, build screens to display or get an input from the users, and so on. If you have been working with Salesforce for many years, you probably see the importance of Flow. Years ago, there was only Workflow Rules and anything beyond updating records was a dream for the admins. After adding continuous enhancements, Flow has become Salesforce's most popular automation tool and the best friend of admins. Moreover, with the new Flow features of the Spring '23 release, Salesforce convinced us that Flow is really giving admins the powers of developers. Now you can make an HTTP Callout from Flow without any code!
HTTP Callout (Beta)
Using the new HTTP Callout (Beta) button from the action element, you can now make calls to external web services.
It is a new beta feature that Salesforce introduced in the Spring '23 release. Although it supports GET calls only (for now), it is a very useful feature. Before this release, you had to build Apex classes in order to make calls to external web services. Now you can make an HTTP callout directly from Flow without using any code. This is a game changer!
This feature is available in any Flow type that contains the action element. For instance, you can build a record-triggered flow to make an HTTP callout when a record meets a criteria.
Let's build a Screen Flow that makes an HTTP callout to bring the current exchange rates for USD.
HTTP Callout to Get Exchange Rates
There are many great APIs that you can find online. In this example, let's use Abstract API's Exchange Rates API.
1- According to their API documentation, the request should be like this:
First of all, let's create a Named Credential in Salesforce. Go to setup, search for Named Credentials and click New Legacy. Enter a name for the Named Credential and enter this for the URL:
Then make the configurations like this:
2- Create a Screen Flow, add an Action element and hit the Create HTTP Callout (Beta) button.
The first screen is for creating an external service. Enter a name and select the named credential that you created. Click Next to go to the second screen.
3- This screen is for creating an invocable action. Give it a name and select the method (only GET option is available for now).
According to the API documentation, you need to pass the API key, base, and target parameters. First two parameters are required. Click Add Key to create the query parameter keys and select their data types.
After adding the query parameter keys, you have to provide a sample API response body. Click New and paste a sample API response body. You can find the sample from the API documentation.
After pasting a JSON-formatted sample API response body, click Review. This will create the data structure.
Click Done to finish creating the invocable action.
4- Provide values for the query parameter keys that you created in the previous step. For example, let's get the exchange rates for Euro and Shekel.
5- Response of the HTTP callout is saved in an Apex defined variable called 2XX. Add a Screen element and display the Euro and Shekel exchange rates on the screen.
At the end, your flow should look like this.
Let's debug the flow. As you can see, current exchange rates are displayed on the screen.
Automatically Update the Exchange Rates In Multi-Currency Organizations
In the previous example, you saw how to display the response on the screen. If you are using multiple currencies, you can create a schedule-triggered flow that runs every day and updates the exchange rates in the setup. This is truly a game changer!
Create a schedule-triggered flow that runs every day and follow the steps above (except for the screen). Then add an Update Records element to update the ConversionRate field of the Currency Type.
Here is the EUR_Rate formula resource.
If you want to use this action in a schedule-triggered flow, add a pause element to wait before calling the action. Otherwise, you might get this error:
"Callout failed for invocable action ExchangeRatesAPI.ExchangeRatesAPI. Can't perform callout when resuming a flow or inside an Apex Queueable. Place the callout to External Services invocable actions before pausing a flow or scheduling an Apex queueable. For more information, contact your Salesforce administrator."
At the end, your flow should look like this:
As you can see, it updated the Conversion Rate of Euro.
There are endless use cases for the HTTP callout feature. Let's see a few more examples.
Here is a callout to convert Gregorian date to Hebrew date. This is a public API of Hebcal and you just need to pass the Gregorian date and it returns the Hebrew date.
Here is another example to validate an email address using the Email Validation API of Abstract API.
Actually, this one is very useful. You can create a REGEX validation rule to prevent entering emails in wrong formats. However, you cannot know if the email address is real or not. For instance, a validation rule cannot catch that this is a fake email address: [email protected]
Using this API, you can check the deliverability of the email addresses and block saving fake data.
HTTP Callout is probably the most important Flow feature of the Spring '23 release. Although it supports only GET calls (for now), there are endless use cases. This feature is really a game changer and I am personally very excited to see the future of Flow. After this point, I think it is safe to say that Flow really gives the admins the powers of developers!