Unify Applications
Logo
Dropdown Data Source Options

Dropdown Data Source Options

Logo

6 mins READ

Connecting Dropdown fields to live data rather than a manual option list keeps your UI in sync with your data without manual maintenance. This page covers how to take a dropdown's options from a data source, map them, and set up search.

unify-applications-dropdown-data-source-options-01-mapped-dropdown-source.png
unify-applications-dropdown-data-source-options-01-mapped-dropdown-source.png

Overview

By default a Dropdown field in a Form block uses options you type in by hand. To take them from a data source, open the Form block's Fields editor and select the Dropdown field. In its Dropdown options section, set Type to Mapped, open Source and choose Use Data Source. Then pick the data source and map fields from each record to the option's label, value and other parts.

Data Source Properties

Property

Required

Description

Data Source

Yes

The data source that provides the option records.

Label

Yes

The field shown as the option label, what the user sees. Example: name.

Value

Yes

The field stored in form data when the option is selected. Example: id.

Description

No

A secondary line of text under the label.

Icon

No

An icon shown with the option.

Color

No

The option's color.

Disabled

No

Shows the option but stops it from being selected.

Visible

No

Hides the option when false.

Show Badge / Badge Label / Badge Color

No

Shows a badge next to the option.

Nested Options

No

A field holding child options, for nested lists.

The Data Source picker and the Label, Value and other rows appear in the panel that opens after you choose Use Data Source, under Mapped Options. Before that, the section shows Label field, which is for options drawn from a platform object; it's hidden once Source uses a data source. Filtering, sorting and paging belong in the data source query, not in the dropdown.

The same Type → Mapped → Source setting, including Use Data Source, is in the options section of Multi select dropdown, Radio Group, Checkbox Group and Currency Input fields. Radio and Checkbox fields have no search settings. See Form Field Types for these field types.

Search Settings

Setting

Options

Default

Description

Search Type

Contains, Starts With

Contains

How typed text is matched against the options.

Search By

Label, Label & Value

Label

Which parts of each option are searched.

Events

Event

Description

On Change

Fires when the selected option changes.

On Focus

Fires when the field gets focus.

On Blur

Fires when the field loses focus.

Example: Country Dropdown

  1. Create a data source that returns countries, sorted by name, for example records with code and name.

  2. On the Dropdown field, set Type to Mapped, open Source and choose Use Data Source.

  3. Pick the countries data source. Map Label to name and Value to code.

  4. The dropdown shows country names and stores the country code on selection.

Example: Active User Picker

  1. Create a data source that returns only active users in the current user's department. Put these conditions in the data source's filters.

  2. Use it as the dropdown's data source. Map Label to displayName, Value to id and Description to email.

  3. Set Search By to Label & Value if users also search by ID.

Tip: When a dataset has more than a few hundred records, limit what the data source returns, for example with filters or a record limit, so the dropdown stays fast.

Dependent Dropdowns

A common pattern is a dependent or cascading dropdown: the options in one dropdown depend on the selection in another. For example, choosing a country first, then showing only the cities in that country.

Cascading country → city dropdowns

  1. Create a cities data source with a filter on the country code. Set the filter's value to the form's country field, for example {{ form1.data.country }} — replace form1 with your form's block ID and country with the Country field's key.

  2. Set the data source's Run Behaviour to Automatic. An automatic data source runs again whenever a value it binds to changes; a Manual one does not.

  3. Use that data source for the City dropdown and map its Label and Value.

  4. When the user changes the country, the data source runs again and the city options update.

Warning: When the parent dropdown changes (for example, the country is switched), the child dropdown's current value may no longer be valid. On the parent field's On Change event, add a Trigger Component Method action that targets the form, choose the Reset Fields method, pick the City field and leave Reset to Default off so the field is emptied. Otherwise the form may submit a city that belongs to a different country. See Form Validation, Methods & Events for all form methods.

Troubleshooting

Symptom

Likely cause

Fix

Dropdown shows no options

The data source has not run, or Label / Value are mapped to fields the records don't have

Run the data source and check its output. Map Label and Value to fields that exist in the records.

Options show blank labels

Label is mapped to an empty or missing field

Map Label to a field that is filled in on every record.

Search misses expected options

Search Type or Search By doesn't match how users search

Switch Search Type to Contains, or set Search By to Label & Value.

Too many or unwanted options

The data source returns every record

Add filters, sorting or a limit to the data source query.