Searching Salesforce Picklist Values in a Flow

Cloud Architect
4 min readJul 10, 2024

--

Summary: Allow users to search through long value sets in Salesforce and select a value. GitHub repository here: andrewwhitten/Salesforce-Searchable-Picklist: Salesforce Searchable Picklist (github.com)

This shouldn’t really be an article. Salesforce supports value sets up to 1,000 items long, and users have been asking for this in an idea sitting dormant since 2010.

In this example I want to record the languages spoken by each Contact with their level of proficiency. The picklist can fast jump to the beginning letter, but what if the list describes the language differently?

I want to add the Gaelic language and press ‘g’. Where is Gaelic? Well, a bit further down under ‘Scottish Gaelic’:

This is not ideal for productivity and data quality; users will take longer and/or enter wrong values in order to complete their tasks.

We can’t change this behavior in the standard Page Layouts, however we can create an alternative way of entering the data through a custom control and a Flow.

I have setup a related list of language to add to:

So, let’s build the Flow first:

Step 1: Setup the Record Id — this is important in order that the Flow knows which Contact to associate with:

Step 2: Create a simple screen flow that takes the input and then creates the record:

The screen should be simple as possible. Here we are starting with two standard picklist controls:

Step 3: Create the record:

Step 4: Add this new Flow to your page:

And now we can add new records with a Flow:

So now we want to enhance the picklist dropdown to be searchable.

Get the code here:

You can alter the code to your picklist — in this example I have a Picklist field called Language__c in the Object Language__c :

import LANGUAGE_FIELD from "@salesforce/schema/Language__c.Language__c";

Make sure you have the right Metadata for the LWC control to work in the Flow:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>61.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__FlowScreen</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__FlowScreen">
<property name="labelText" type="String" label="Label text for the picklist" description="Label of picklist" role="inputOnly" />
<property name="picklistValue" type="String" label="Picklist value" description="xyz" role="outputOnly" />
</targetConfig></targetConfigs>
</LightningComponentBundle>

Test out locally to ensure the search ComboBox works (don’t worry about the sizing)

Now we want to replace the language picklist in the Flow with our new custom control:

And try it out!

But wait, we can also use this same Flow in a Quick Action!

Notes:

  • Attribution: The LWC code was adapted from this StackOverflow post by Anton Kutishevsky on Github. I made some changes to use a Global Value Set and added Flow metadata
  • Editing records: the searchable ComboBox won’t appear when you edit records later. You could create a similar custom screen for this though.
  • Flow building: I didn’t go through every single step to building the Flow. It was simple but this assumes you know how to put it together — you can deploy the full solution to check everything.
  • Specifying Picklists dynamically: Ideally the LWC control will be generic, and you just pass if the Picklist reference at runtime — you will probably need to write an Apex method for this such as here: Various Methods For Associating Picklist Values in Lightning Web Components (LWC) — SFDCian — Best Salesforce Consultant & Architect
  • Non-Flow use: Also good! Just change the metadata targets of the LWC control for your scenario

--

--

No responses yet