1. Help
  2. Features
  3. Dynamic dropdowns

Dynamically Sourced Dropdown Options

Introduction

Options for a dropdown field are generally static and are defined in the form builder. However, there are cases where you might want to fetch the options for a dropdown from a remote source dynamically.

When editing the dropdown field go to the Options tab. Here click on Source to see the list of possible sources for the options (the default being List):

Source list for dynamic dropdown options
Sources for dynamic dropdown options

Remote URL

This allows you to fetch the options from a public URL. The URL must return the options in this format:

{
  "total": 100,
  "data": [
    { "value": "1", "label": "Option 1" },
    { "value": "2", "label": "Option 2" },
    { "value": "3", "label": "Option 3" }
  ]
}

You can use our demo endpoint https://api.formcrafts.com/public/options to test this feature.

Remote URL source for dynamic dropdown options
Using the remote URL source

Click on the Preview button on the top-right corner to see the options fetched from the remote URL.

There are two configuration options when using the remote URL source:

Enable pagination: When enabled, the dropdown will request the options in chunks. Example, when the user first opens the dropdown it will request the first 25 options. When the user scrolls down it will request the next 25 options and so on. We will append skip and take as query parameters to the remote URL.

Remote search: When enabled, the dropdown will send the search query to the remote URL, allowing the remote server to filter the options based on the search query. We will append an s query parameter to the URL to achieve this.

Together, these two options allow you to connect your dropdown to a source with any number of options.

You can also reference other fields in the remote URL. This allows you to fetch options based on the value of another field. For example, if you have a dropdown for countries and a dropdown for states, you can fetch the states based on the selected country:

Remote URL source for dynamic dropdown options, with field references
Using the remote URL source, with field references

Google Sheets

You can fetch dropdown options from a Google Sheet.

For example, we have a Google Sheet with the following data:

Google Spreadsheet with contact records
Google Spreadsheet with contact records

We want the option labels to be fetched from the Name column (range A2:A11), and the option description from the Email column (range B2:B11).

We will configure the Google Sheets source as follows:

Dynamic dropdown options via Google Sheet
Using the Google Sheet source

Click on the Preview button on the top-right corner to see the options fetched from the Google Sheet.

Salesforce

Please read the Salesforce documentation for more information on how to fetch options from Salesforce.