Dynamic picklists are one of the most powerful features of FormCrafts. Salesforce picklists created in FormCrafts have many features, like:

  • Data is fetched in real-time
  • Options are searchable
  • There is no limit on the maximum number of options
  • Options have support for descriptions and photos
  • Options can be grouped
  • Support for multiple selections

The simplest example of a dynamic picklist would be a dropdown that allows users to select a contact.

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

Salesforce dynamic picklist basic setup
Salesforce dynamic picklist basic setup

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:

Salesforce dynamic contact picklist
Salesforce dynamic contact picklist

We will explore various configurations below, but here is a primer:

  1. 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.
  2. Label field
    This is the main option text displayed to the user. For Contact it makes sense to use Full Name.
  3. Description field
    This is the optional description text for the option. We will leave this blank for now.
  4. Image field
    This is the optional image field for the form. We will leave this blank for now.
  5. 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.

Option 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:

Option 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:

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:

Using SOQL

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:

Salesforce SOQL-generated dynamic picklist configuration
Salesforce SOQL-generated dynamic picklist configuration

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

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:

Salesforce dynamic picklist with option templates
Salesforce dynamic picklist with option templates