Create Filtered Lookup with Choice Lookup

Create Filtered Lookup with Choice Lookup

Last Updated on December 25, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

  • How do you use the new choice lookup (beta) component to display filtered records? 

This blog is a sequel to my previous blog – Select Multiple Records in the Lookup ComponentIn the previous blog, I discussed how to configure the Lookup flow screen component so that users can search and select more than one record.

This article goes a step ahead and explains how to configure the new choice lookup (beta) flow screen component to display filtered records.


After reading this blog, you’ll be able to:  

  • Create a Screen Flow and add a Screen element to it.
  • Add a choice lookup (beta) component to your screen element
  • Display filtered records using the collection choice set
  • Display filtered records using the record choice set
  • And much more

Business Use case

Edward Backhouse is working as a System Administrator at Gurukul on Cloud (GoC). He has received the following requirement from the management:

  1. Add a screen flow on the home page that allows users to select multiple opportunities
  2. In the end, update the selected open opportunity to closed lost.

Automation Champion Approach (I-do):

With the Spring’23 release, it is now possible to add a filter lookup component using a brand new choice lookup (beta) screen flow component. Using a filtered Collection Choice Set or Record Choice Set, you can create a Lookup that displays open opportunities, unqualified leads, or contacts from a previously selected account in the screen flow.  

Before we proceed further, let us understand the characteristics of the Choice Lookup component.

Attribute Description
API Name An API name can include underscores and alphanumeric characters without spaces. It must begin with a letter and can’t end with an underscore. It also can’t have two consecutive underscores.
Label User-friendly text that displays to the left of the component.
Require Requires users to enter a value before they can move to the next screen.
Placeholder Text Text that appears in the field when it’s empty. Use placeholder text to give users a hint about what to enter in the field.
Choice Add at least one choice, record choice set, or collection choice set to this component. Available only when you add a choice component to the screen component.
Default Value Pre-selected choice for the component. If the associated screen isn’t executed or the conditions for component visibility aren’t met, the stored value of the component is null.

Use the chart provided by Adam White  to understand when to use which lookup component.

Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understand it.

Let’s begin building this automation process.

Guided Practice (We-do):

There are 4 steps to solve Edward’s business requirement using Screen Flow. We must: 

  1. Define flow properties for screen flow
  2. Add a Screen element
    1. Create a Record Choice Set to generate a filtered list of open opportunities.
    2. Add a Choice Lookup (Beta) Component that allows users to select an open opportunity.
  3. Add an Update Records element to update the opportunity Stage to Closed Lost.
  4. Add a screen flow to the lightning home page

Step 1: Define Flow Properties

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows, then click on the New Flow.
  4. Select the Screen Flow option and click on Create and configure the flow.
  5. It will open the flow designer for you.

Step 2: Add a Screen Element 

  1. On Flow Designer, click on the +icon and select the Screen element.
  2. Input the following information:
    1. Enter Label the API Name will auto-populate.
  3. Click Done

Step 2.1: Add a Record Choice Set to Generate a Filtered List of Open Opportunities

  1. Under Toolbox, select Managerthen click New Resource to create a record choice set to generate a filtered list of open opportunities. 
  2. Input the following information: 
    1. Resource Type: Record Choice Set
    2. API Name: recChoice_OpenOpportunities
    3. Object: Opportunity
    1. Filter Opportunity Records
      1. Row 1:
        1. Field: IsClosed
        2. Operator: Equals 
        3. Value: {!$GlobalConstant.False}
    2. Configure Each Choice
      1. Choice Label (Select a field that generate label for each choices): Name
      2. Data Type (Data type of the choice’s value): Text
      3. Choice Value (Select a field whose value you want to store when the user selects this choice at run time): Id
  3. Click Done.

Step 2.2: Add a Choice Lookup (Beta) Component to Display Filtered List using Record Choice Set

  1. Under Input section on Screen Element. Drag and drop Choice Lookup (Beta) onto the screen. 
  2. Input the following information:
    1. Enter Label and API Name.
    2. Require: Selected
    3. Choice: {!recChoice_OpenOpportunities}
  3. Click Done.

Step 3: Add Action – Update Records

The next step is to update the selected opportunity Stage to Closed Lost. We will use the Update Records element. 

  1. On Flow Designer, click on the +icon and select the Update Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. For How to Find Records to Update and Set Their Values select Specify conditions to identify records, and set fields individually
  4. Object: Opportunity
  5. Select All Conditions Are Met (AND)
  6. Set Filter Conditions
    1. Row 1:
      1. Field: Id
      2. Operator: Equals
      3. Value: {!Open_Opportunity.selectedChoiceValues}
  7. Set Field Values for the Opportunity Records
    1. Row 1:
      1. Field: StageName
      2. Value: Closed Lost
  8. Click Done.

In the end, Edward’s Flow will look like the following screenshot:

Once everything looks good, perform the steps below:

  1. Click Save.
  2. Enter the Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 57
  5. Interview Label: Choice Lookup Example {!$Flow.CurrentDateTime}
  6. Click Save.

Almost there! Once everything looks good, click the Activate button.

Step 4: Add a Screen Flow to the Lightning Home Page

The next step is to distribute a flow to Lightning Experience or Salesforce app users by embedding it on a Lightning home page.

Proof of Concept

Formative Assessment:

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

One thought on “Create Filtered Lookup with Choice Lookup

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.