How to Create a Dynamic Picklist for Salesforce Forms
Dynamic picklists could become the most powerful feature of your Salesforce forms. A simple web-to-lead form created in Salesforce uses basic HTML picklists, which are not very useful.
What makes a picklist dynamic?
A dynamic picklist would contain options that are fetched live from another source, while also providing an easy interface to select the correct option(s). Example, a dynamic picklist on your Salesforce form could allow you to pick from a list of contacts in your Salesforce account.
Dynamic picklists have many other features like:
- Options are searchable
It is not feasible to expect the user to scroll through all the options of a dynamic picklist to find the correct one. Picklists should have the option to search options. - There is no limit on the maximum number of options
What if your picklist can potentially have 10,000 possible options. It is not feasible to load all options in advance. A good dynamic picklist would allow users to select any of these 10,000 options while not loading all of them in advance. - Options have support for descriptions and photos
Your options can be accompanied by descriptions or photos. - Options can be grouped
- Support for multiple selections
- Picklist options can be dependent on other fields
This is a very powerful feature, and often overlooked. Example your dynamic picklist allows users to select from a list of contacts for a particular country. However the user can also select the country here in another field. A dynamic picklist can have a set of options that depend on the value of another field.
Here is what a dynamic picklist would look like on your Salesforce form
Creating dynamic picklists in Salesforce
This is where FormCrafts comes in. FormCrafts is a form builder for Salesforce that comes with a huge feature set, and one of them is dynamic picklists. Let us learn how to create dynamic picklists in FormCrafts.
Basic setup
Create a new form on your FormCrafts dashboard, if you haven't already.
On the form edit screen click on Salesforce (top-left) and click on Connect an organization to link your Salesforce organization.
Next click on Add Field (top-right) and click on Dropdown. Note that dynamic picklists only work with dropdown-type fields. When editing the dropdown field look for Dynamic Source, next to Option List.

When you click on (select source) you would be able to see a list of Salesforce objects you can pull data from. Search for Contact. You will now see 5 other columns:

We will explore various configurations below, but here is a primer:
- Id field
This is the value of your option. In most cases we want the value to be the unique Id of your record. For Contact that would be Contact ID. For Account that would be Account ID. - Label field
This is the main option text displayed to the user. For Contact it makes sense to use Full Name. - Description field
This is the optional description text for the option. We will leave this blank for now. - Image field
This is the optional image field for the form. We will leave this blank for now. - Group by field
This is the optional group creation parameter. This would usually be something with recurring values like Department or Country.
For this example select Contact ID under Id field, and Full Name under Label field. Now click on Preview (top-right) and try it out.
Adding description
Adding description to your picklist options is fairly straightforward. Simply select a field under Description field. For this example we want to show a contact's country as the description so we would select Mailing Country.
Here is how our picklist looks now:
Adding photos
You can even add photos to your options. For this to work your Salesforce object must have a URL field that links to an image. Let us select Photo URL under Image field.
Here is our picklist now:
Some examples where you'd want to add photos to a dynamic Salesforce picklist:
- A logo selection picklist
- A contact selection picklist
- A travel destination selector
Grouping options
You can group your picklist options using the Group by field. Here we would select a recurring field in our Contact record. Example, this could be department, country, industry type, etc ... For this example select Mailing Country.
Here is our picklist now:
Some examples where you'd want to add groups to your Salesforce dynamic picklist:
- A contact picklist
- A city picklist
- A product selection picklist
Using SOQL
Basic usage
Let's go back to the step where we selected the Contact object from the list under Dynamic Source. Click on the field again and select Salesforce SOQL. This now allows us to use SOQL queries to fetch records, giving us a lot of flexibility. For this example we will try to fetch Contact records, and their associated id, name and email fields. The SOQL query is:
select id, name, email from Contact
Under Id field, type in id. Under Label field type in name, and under Description field type in email. Our configuration looks like this:

Relationship queries
You can also use relationship queries to lookup related records and then populate that information in the picklist. Example, we want to fetch a list of contacts. Our option label should be the contact's full name. We want our option description to be the name of the associated account. The SOQL query here would be:
SELECT id, name, Account.Name FROM Contact
And under Description field we would type in: Account.Name
Dependent picklists
The options of your picklist can depend on the values selected in other fields. Example we have a main picklist that fetches a list of Accounts. Then we have another picklist that only shows a list of Contacts associated with the above selected Account.
Let us add another dropdown field to our form and configure this field to pull all Accounts. Our configuration would look like this:

Note the field Id for this field. It should be in the format fieldXX.
Now configure the Contact picklist field to use Salesforce SOQL (under Dynamic Source). We will use this query to fetch results:
SELECT id, name, Account.name FROM Contact WHERE Account.Id = '[field17]'
Here you would replace field17 with the field Id of the Account field from above. So the Contact picklist is using the SOQL query to fetch the id, name, and Account name of all Contacts where the Account Id matches the Account Id of the field above.
Here is our configuration for the Contact picklist:

Here is this setup in action:
Using templates
What if we want the option description to have a particular format, like Works at XXX instead of simply the Account name?
That is also possible. In the above example, under Description field, type in:
Works at [Account.Name]
Our configuration now looks like this:

Dynamic picklist builder
FormCrafts offers a dynamic Salesforce picklist builder that can help you preview your picklist options, and also debug common issues. To access the picklist builder look for the button Picklist builder under Dynamic Source while editing your field.
