Skip to main content

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.
Note

Accessibility

This unit requires some additional instructions for screen reader users. To access a detailed screen reader version of this unit, click the link below:

Open Trailhead screen reader instructions.

Introduction

This project walks you through the motions of building a simple flow. Launch your Trailhead Playground now to follow along as we complete this project. 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. To open your Trailhead Playground, scroll down to the hands-on challenge and click Launch. 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.
  3. Make sure Start from Scratch is selected, and click Next.
  4. Select Screen Flow and click Create.
  5. On the flow canvas, on the path after the Start element, click Add Element.
    The location of the Add Element node
  6. Select Screen. The New Screen window opens.
  7. For Label, enter Contact Info.
    The API Name is automatically set to Contact_Info. Label and API Name fields under Screen Propertie
  8. Click Done. The canvas now includes three items: Start, Contact Info, and End.
    The Flow Builder canvas, showing Contact Info between Start and End
  9. Click Save, and enter these values.
    • Flow Label: New Contact
    • Flow API Name: New_Contact
  10. Click Save.

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. Click the Toggle Toolbox button to view the Toolbox.
  2. In the Manager tab, click New Resource.
    The New Resource button in the Manager tab
  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.
    The Manager tab, showing the contact 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 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.
  4. In the properties pane, for API Name, enter contactName.Edit Screen page, showing the properties pane
  5. Scroll down and click Advanced. Make sure Manually assign variables 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 then select FirstName.
      Properties pane, showing the value of the First Name field under Store Output Values
    2. For Last Name, select contact then select LastName.
  1. Click Done.
  2. 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.
    • Label: Account
    • API Name: Account
    • Data Type: Text
  5. In the Configure Choices section, for Choice, select New Choice Resource. Enter these values.
    • Resource Type: Record Choice Set
    • API Name: accounts
    • Object: Account
    • Condition Requirements: None—Get All Account Records
    • Choice Label: Name
    • Data Type: Text
    • Choice Value: Id
    • In the Store More Account Field Values section, enter these values to store the ID of the user-selected account in the contact record variable.
      • For Field, select Id.
      • For Variable, select contact then select AccountId.
  1. Click Done twice.
  2. 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.
    • API Name: update_toggle
    • Label: If this contact already exists, update the existing record.
    • Active Label: Update existing
    • Inactive Label: Create other contact
  4. Click Done.
  5. Click Save.

Close and Open the Flow

  1. To exit Flow Builder, click the back arrow.
    Flow Builder, showing the location of the back arrow
    The All Flows list appears.
  2. To reopen the flow in Flow Builder, find New Contact on the All Flows list, 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.
    Flow Builder, showing the location of the Run button
  2. Enter any values, select any account from the list, 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.

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback