Screen Flow Basics

Ashwin Kumar Srinivasan
5 min readSep 29, 2019

This blog focuses on screen flow basics. To build forms without using custom code in lightning to embed them on the record page or use it as an action.

Use-case: This is a flow assuming a case is created in Salesforce and the internal team needs to update notes on the case and provide details.

Pre requisites

Create custom fields on case object

  • Team Comment — Text Area (Team_Comment__c)
  • Team Response Date — DateTime (Team_Response_Date__c)
  • Defect Agreed — Checkbox (Defect_Agreed__c)
  • Action Comments — Text Area (Action_Comments__c)

How to build a simple screen element?

Step 1: Setup → Process Automation → Click “Flows” → Click “New Flows” → Select “Screen Flows”

Step 2: Drag and drop the screen element on to the canvas

Drag and drop the screen element

Step 3: Add screen components to the screen based on the field type

Add Long text Element with the Label “Team Comment”

Add Long text Element

Step 4: Add Date & Time Element with validation to check if the date is not in the past.

Drag and drop the screen element “Date & Time” from the Screen Components on the sidebar. After providing the label for the screen element go to Validate Input Section and provide the Formula to validate and add Error Message.

Note: Unlike validation rules in the Object Manager, the validate input formula must be evaluated to false in the flow screen validations.

Screen element validation

Step 5: Screen Element Visibility by Condition (Winter ‘20)

In the upcoming release there is an additional section on the screen element to define the visibility of the element called Set Component Visibility

Select the component on the screen which needs conditional visibility, here in our example we are displaying “Defect Action Comment” only if the “Defect Agreed” is True (Defect Agreed is a checkbox screen component added which is skipped in the steps above).

To set filter for component visibility
Debug screen capture to show the conditional element

Save the flow and Debug

At any point while building a flow save the flow to debug and evaluate the correctness of what we build.

Saving the flow with the name Basic Screen Flow

On the top right corner of the flow builder if you click on Debug it will navigate to a new url as shown in the below gif.

Flow debug to test the screen build

Update the record using values provided

Step 1: Create a record variable to store the form input value and update it.

In the toolbox click on the Manager Tab and click “New Resource” and select the following in the form given.

Resource type as “Variable”, API Name “CaseRecord”, Datatype “Record” and Object as “Case”

Creating a new resource of type variable with datatype as record
Create a case record variable to be used for updating the record

Step 2: Create a recordId Variable using Manager Tab and New Resource in the Toolbox

Datatype of the variable is “Text” and Mark it as Available for Input

Note: The recordId variable should be created case sensitive as it is, in case the flow is planned to be used as an action.

Step 3: Drag and Drop “Assignment” from Toolbox → Elements → Logic

The screen values can be mapped to the record variables we have created in the first step.

Assign the variables from the Screen element to the CaseRecord Variable’s fields

Step 4: Drag and Drop “Update Records” from Toolbox → Elements → Data

Update the Record or Record Collection with the caseRecord variable created in the earlier steps.

Update Records

Step 5: Save the flow and Activate it.

Making use of the flow created in Lightning

1. Embed the flow on lightning app builder page

To embed the flow in the lightning app builder page (record page in this instance)

Step 1: Edit page on the record or go to App builder and edit the page.

Step 2: Drag and drop the flow element from standard components.

Step 3: Set the designer attribute variables on the right sidebar where the

Flow in our instance is “Basic Screen Flow”.

Layout select One or Two as you would prefer.

Pass Record Id Variable in this Attribute” we are setting the recordId as the variable in this attribute which we have created in the Step 2 of “Update the record using values provided” section.

App builder page to add flow

This is a good option to migrate visualforce pages to lightning where instead of embedded visualforce page which can be converted into a flow; we can now use a flow in the record page in lightning.

2. Quick Action

Step 1: Object Manager Tab → Case → Buttons, Links, and Actions → Click New Action on the right side bar

Step 2: Select Action Type as Flow, Flow pick “Basic Screen Flow” from the picklist

Flow Action

Step 3: Add the screen flow in the case page layout under the “Salesforce Mobile and Lightning Experience Actions”

For case object, the custom action appears on the feed. Since feed is enabled, this does not appear as an action button on the record page.

Note: The variable to store record id should be created as recordId (CaseSensitive)

To Populate the Existing Values on the flow screen

To display the saved value we need to retrieve the value before the screen element and set defaults.

Step 1: Drag & drop Get Records from Toolbox and set it up. From winter 20 there is an option where it creates the variable to store the value automatically, named as Get_Case (since the Get Records api name is Get_Case). There is an option to manually assign the variable to custom variable which we have not done in this step.

Note: All field values required in the screen element has to be queried

Get Records

Step 2: In the screen elements assign defaults from Get_Case element, since queried element are stored in the autogenerated variable.

Default Screen Values

Note: We could have used one record variable System Created “Get_Case” or the manual one “CaseRecord”.

And this is how our flow looks like :)

Simple Screen Flow

Please provide any comments or feedback.

--

--