Collect Contact Info from Your User

Learning Objectives

In this project, you’ll use Flow Builder to build a working flow that:
  • Captures information from a user.
  • Queries your Salesforce org for a record that matches what the user enters.
  • Decides whether to update the matching record or create a new one.
  • Creates or updates a record.

Introduction

This project walks you through the motions of building a simple flow. As you complete this project, don’t worry about understanding everything. Follow the instructions and observe how the various controls work in Flow Builder. By the end of this project, you’ll have a working flow. Later, you add to this flow as you complete the Flow Builder module. As you complete that module, you learn all about the flow building blocks that you use in this project. For now, gain some muscle memory as you repeat the flow-building pattern of drag or click, configure, and save. Let’s get started!

Create the Flow and Add a Screen

  1. From Setup, enter Flows in the Quick Find box, then select Flows.
  2. Click New Flow, select Screen Flow, click Next, and select Freeform.
  3. From the Elements tab in the toolbox, drag Screen onto the canvas. Flow Builder, showing where to drag the Screen element from the toolbox to the canvasNew screen opens.
  4. For Label, enter Contact Info.
  5. The API Name is automatically set to Contact_Info. Label and API Name fields under Screen Propertie
  6. Click Done. The canvas now includes two items: Start and Contact Info.
  7. Drag the connector node at the bottom of Start onto Contact Info. The two canvas items are now connected.
    Canvas, showing where to drag the connector node from Start to “Contact Info”
  8. Click Save, and enter these values.
    Field Value
    Flow Label New Contact
    Flow API Name New_Contact
  9. Click Save.
  10. Throughout this project, if warnings appear, ignore and close them when you save the flow. You can always read warnings later by clicking Warning icon.
    Warnings, showing controls for closing and reopening them

Create a Record Variable for the Contact

Because you plan to capture contact information from the user, let’s create a record variable to store that contact record data in the flow.

  1. In the Toolbox, click the Manager tab.
    Manager tab location in the toolbox
  2. Click New Resource.
  3. For Resource Type, select Variable.
  4. For API Name, enter contact.
  5. For Data Type, select Record.
  6. For Object, enter Contact.
  7. Click Done. In the toolbox, the Manager tab now contains a contact record variable resource.
    Manager tab with “contact” record variable
  8. Click Save.

Add a Name Input Component to the Screen

You need to create form fields for the user to enter contact information on the screen. Let’s start with an input component that collects the contact’s name.

  1. On the canvas, double-click the Contact Info screen. The Edit Screen window opens.
  2. In the Screen Components pane, enter Name in the search box.
  3. Drag Name onto the screen canvas.
    Edit Screen page, showing where to drag the Name input component from the screen components pane to the screen canvas
    The properties pane now represents the Name input component.
    Edit Screen page, showing the properties pane
  4. In the properties pane, for API Name, enter contactName.
  5. Scroll down and make sure Manually assign variables (advanced) is selected.
  6. Complete these steps to take what the user enters in the First Name and Last Name fields and store those values in the contact record variable.
    1. For First Name, select contact and then FirstName. The value is displayed as {!contact.FirstName}.
      Properties pane, showing the value of the First Name field under Store Output Values
    2. For Last Name, enter {!contact.LastName}.
  7. Click Done.
  8. Click Save.

Create a Record Choice Set for Accounts

You want the user to specify the parent account for the contact. Let’s create a record choice set for use later as a picklist on the screen.

  1. From the Manager tab in the toolbox, click New Resource and select Record Choice Set from Resource Type menu.
  2. In the New Resource window, enter these values.
    Field Value
    API Name accounts
    Object Account
    Condition Requirements None—Get All Account Records
    Choice Label Name
    Data Type Text
    Choice Value Id
  3. In the Store More Account Field Values section, complete these steps to take the user-selected account and store its ID in the contact record variable.
    1. For Field, select Id
    2. For Variable, enter {!contact.AccountId}.
  4. Click Done.
    In the toolbox, the Manager tab contains an “accounts” record choice set
  5. Click Save.

Add a Picklist Input Component to the Screen

Now let’s add the picklist for the user to select the contact’s parent account.

  1. On the canvas, double-click the Contact Info screen.
  2. In the Screen Components pane, enter Picklist in the search box.
  3. Drag Picklist onto the screen canvas just below the Name component.
    Edit Screen page, showing where to drag the Picklist input component from the screen components pane to the screen canvas
    The properties pane now represents the Picklist input component. Edit Screen page, showing the Picklist properties
  4. In the properties pane, enter these values.
    Field Value
    Label Account
    API Name Account
    Data Type Text
  5. In the Select Choices section, for Choice, enter {!accounts}.
  6. Click Done.
  7. Click Save.

Add a Toggle Input Component to the Screen

Now let’s add the toggle for the user to specify whether (or not) to update an existing contact if one is found.

  1. On the canvas, double-click the Contact Info screen.
  2. From the Screen Components pane, drag Toggle onto the screen canvas just below the Account picklist component. Toggle input component on the screen canvas
  3. In the properties pane, enter these values.
    Field Value
    API Name update_toggle
    Label If this contact already exists, update the existing record.
    Active Label Update existing
    Inactive Label Create other contact
    Manually assign variables (advanced) unchecked
  4. Click Done.
  5. Click Save.

Close and Open the Flow

  1. To exit Flow Builder, click the back arrow.
    Location of Back link
    The flow list page appears.
  2. To reopen the flow in Flow Builder, find New Contact on the flow list page, and click it.

Run the Flow to View the Screen

At this point, your flow can collect contact information from the user and store that information in flow variables. Let’s see what the screen looks like to users who run the flow.

  1. Above the canvas, click Run.
    Location of Run button in Flow Builder
    If you see an error message that says we can’t display a component because it isn't supported in Classic runtime, that means you're using an older Salesforce org. Not to worry! A quick settings change is all you need. From Setup, enter Process Automation Settings in the Quick Find box, then select Process Automation Settings. Select Enable Lightning runtime for flows, and click Save. Now reopen your flow, and click Run.
  2. Play with the screen components and click Finish.
     Screen of running flow

Because the flow has no elements to execute after the screen, nothing happens when the flow finishes. The flow simply runs again, which means that you see the screen again.

Congrats on building and even running a flow! So far, the flow only displays a screen that accepts user input. Next, you configure the flow to compare some of that user input with data in your org.