Newsletter

HTTP Callout and Screen Flows

FlowFest v5

Last week I judged for the fifth FlowFest. I cannot believe we have five FlowFests behind us. The challenges were extra difficult this time. Two functionalities that came up repeatedly were the HTTP Callout and the data table component.

I will write about these topics.

You may remember. I wrote about the HTTP Callout GET method when it came out in beta. Now this functionality is in GA. Read the blog post here and watch the YouTube recording here. It shows you how to build a flow that can check the validity of a phone number.

GET functionality is limited. If you want to harness HTTP Callout’s full power, you need the POST method. POST is now available in beta as of the last release. You can find my previous post about how to build an HTTP Callout to shorten long URLs here.

Read the three-part blog series here.

I thank all the organizers, sponsors, judges, and participants of FlowFest.

This post was originally made to LinkedIn on July 14th, 2023.

Read the previous post: What Can Flow-Builders Do With Pen and Paper?

Standard
Newsletter

Shorten URLs Using the HTTP Callout POST Method

HTTP Callout in Spring 23 got many people excited. The blog post and the video by Josh Dayment and I drew quite some attention. We heard one criticism for this functionality: the solution was incomplete without the POST method.

With Summer 23, the Salesforce Flow Product Team not only moves the GET method to GA, but also gives us the POST method in Beta.

The use case we picked for this demo is based on a real-life client requirement. The client wants to shorten the long URL links before they send them to customers via email or text. Read on for a link to the three-part blog on this topic.

First, let’s dive into the background information: Until recently, API access was reserved for developers. Flow automation did not deal with APIs much. 👨 💻

But what does this functionality do? 🚨

This feature creates an invocable action powered by External Services to connect your flow to an HTTP-based API without using code.

What is an API? 🔁 

API (Application Programming Interface) is a program mediator that allows two applications to exchange data and complies with HTTP and REST standards. API refers to standards and documentation that describe how to create or use such a connection or interface.

What is the GET method? ⬅️

The GET request method is used to fetch data from the server. Example: Send Postal/ZIP-code to receive City in the response. Another example: Send phone number, receive the telecom carrier.

What is the POST method? ➡️

The HTTP POST request method sends data to the server. The HTTP POST method creates or updates a resource on the server. POST is one of the most widely used methods of the HTTP protocol. The HTTP POST method is used to submit web forms, upload files and images to the server.

Read the three-part blog on this topic here. Also, check out the GET blog post while you are on the site.

This post was originally made to LinkedIn on June 5th, 2023.

Read the previous post: What I Learned From The Jobs I Held Growing Up

Read the popular post: HTTP Callout in Salesforce Spring 23 – GET

Standard
Flow, New Release

HTTP Callout in Salesforce Spring 23 – GET

With each new release lately the Salesforce Flow team has been bringing some amazing features. I am really excited about the introduction of HTTP Callout (Beta) in Spring 23′. It really starts to open up the possibility of more resources for admins to start doing more with clicks and not code. This allows an admin directly inside of flow to make an HTTP Callout to perform a Get on an external system previously this would require either an invocable apex action or an external service be created in Salesforce. Andy and I took sometime over the last couple of weeks to test it out and you can see our video here to see our discussion and brief demo but let’s take a deep dive walkthrough on how we configured it and the steps to take. For this testing and demonstration we found a simple api that has a free use tier that allows for a set number of callouts to validate a phone number and return validation information you can find more on Api Layer and the documentation here.

Before you can create an HTTP Callout you first need to create a what’s called a Named Credential a Named Credential is what Salesforce uses to validate you are able to use the external service you are making the call to.

Step 1 in Setup go to Named Credentials

Step 2 Click on External Credentials then click on New (yes we are doing this before creating our Named Credential because we are going to use it in our Named Credential)

Step 3 Enter the initial details for your External Credential

Step 4 After hitting save scroll down on the new External Credential until you see Principals and click on New

Step 5 Enter in your Principal details this is what the API service will use to authenticate

Step 6 Click on New in Custom Headers and we are going to create the header to pass through our authentication

Step 7 Create one more header to set how to accept the data from the api service

Step 8 Go to the Named Credentials tab and click on New

Step 9 Enter the details of your Named Credential and click save

Step 10 Allow users the use the External Credential. I created a permission set to handle permissions.

Step 11 New Fields I created 2 fields on the Lead Object Phone_Number_Details__c a rich text field to hold the information about the phone number that will get returned in the callout and I also created a checkbox field called Phone_Number_Validated__c that is checked true or false if a phone number has been validated in the service

Step 12 Let’s make a flow – In this example I am using a record-triggered flow that will fire when a lead is created. I set two conditions on Phone to make sure this fires only when there is a value in the Phone field. I also marked it to include an Asynchronous path since we can only make a callout Asynchronously.

On the asynchronous path click on the “+” and then add an action

After clicking on action a modal will pop up and you will want to scroll down to the bottom of the left panel and click on “Create HTTP Callout (Beta)”

Next fill out the details for the HTTP Callout Action you are creating the name is all one word no special characters or spaces, make sure to add a description because you will be able to reuse this in other flows without a need to create a new one so make it easier on other admins, devs and your predecessors so they know what it does, and finally choose the named credential you created in Step 1.

On the next screen we want to give it another label and description along with setting our Method which in the beta is only GET which means we can only retrieve data from an external service. We can also optionally set a URL Path in this case we will use ‘/validate’ this path comes from our api documentation that says this is what we want to do on the service. We are also going to set some Query Parameter Keys this is the data we want to send to our service for our use case we want to send the apikey and the number both of them have a datatype of string we use the names and data types that are from the api documentation; I also made both required otherwise the call will fail. The task is to give an example of what a successful json response will look like once again we get this from our API Documentation. After you paste your example click review and you should see the data structure on the right click done.

Step 13 Configure the new action you created. Give it a name and description like all best practices. In the apikey input I am referencing the label I created in step 3 using the global variable for label and in the number field I am referencing the phone file using the Record Variable from the lead

Step 14 Almost done I created a text template to populate the Phone Details Field I created. In the text template I am referencing the outputs from my service I just created it will create what’s called an Apex Defined Variable I can reference specific pieces of data.

Step 15 Update the Lead Here I am updating the Lead Record that is my Triggering Record updating the Phone Validated and Phone Detail fields.

Step 9 Debug, Validate, Activate, Deploy – Next up debug your flow make sure you set to debug on the asynchronous path and review your debug details and validate it is doing what you expect. Once it’s validated activate your flow and deploy it 🙂

Step 16 Take a deep breath exhale, pat yourself on the back, put on your superhero cape, and enjoy your drink of choice

Views and opinions in this article are my own and do not represent that of Salesforce

To read about the HTTP Callout POST method, click here.

Note: To watch the demo on Youtube, click below.

Standard