In this article we will learn how to write a simple flow to show the customary "Hello World" message to the user.
Let's start by creating a new flow using the "New Flow" button in the flow list page.
Clicking he "New Flow" button will open the flow builder in a new tab. On this screen you will see options to create different types of flows. For the purpose of this article we will select "Screen Flow" and click on "Next" button.
In the next screen you will get options to select the type of layout that you want to use for creating the flows. You can use either of the options, but I would recommend you to try the "Auto Layout" option which is in Beta at the time of writing of this article. Free-Form layout allows you to place the elements on the screen at any position while the auto-layout has fixed positions. A flow can contain lots of elements and it can grow quite huge in size. A free form layout can look quite messy in such big flows. It can become quite difficult for the person to read and understand the flow in such a situation in case of free form layout.
Next you will be shown a blank canvas screen of flow builder. This is where we will be building our flow.
Click on the "New Resource" button. This option will allow us to create different types of variables , constants, template text etc. Variable is something that can change in a program. This is where we store data in our program which is further manipulated in the flow.
We will see and use the different types of resources in future articles. For the purpose of this article, let us select a resource type of "Variable"
Configure rest of the values as below and click on "Done"
| |
| This variable stores text to be displayed on screen |
| |
| |
Now click on the "+" button shown.
Now you will see options to "Add Elements" to the flow. Below are the options available.
Interaction Elements
- Screen - Collect information from users who run the flow or show them some information.
- Action - Perform an action outside of the flow. Choose from your org’s custom create and update actions or an out-of-the-box action, like Post to Chatter or Submit for Approval.
- Subflow - Launch another flow that’s available in your org.
- Assignment - Set Variable Values
- Loops - Iterate over a collection of values or records.
- Sort - Sort items in a collection.
Data
- Create Records - Create Salesforce records using values from the flow.
- Update Records - Update Salesforce records using values from the flow.
- Get Records - Find Salesforce records, and store their field values to use later in the flow.
- Delete Records - Delete Salesforce records.
Since we want to show "Hello World" message to the user, select the screen element.
On the left hand side palette you will see a list of prebuilt components. For now scroll down and select the "text" component. As soon as you click it, that element will be added to the screen element.
Give a label, example - "Hello World". API name will be auto populated. Now in the default value, select our previously created variable - strHelloWorld
Select the header element and enter below details, click on done
Screen element will be added to the flow builder canvas
Now we will save the flow and run it to see the output. Click on "Save" button and provide a name to the flow, API name will be auto populated.
Click on run button after saving the flow.
The flow will be executed, a new tab will show the output of the flow. You can see the "Hello World
text on the screen.
Congratulations we have just built and run our first flow!