Question type

lookup

A question type that queries a list asset and returns a structured record. ZIP screenouts, state → region pipes, employee directories, make → model cascades.

What lookup is

lookup is the question type for picking a record out of a list asset — a CSV, JSON list, or remote endpoint that lives outside the YAML. The respondent types or selects; the runtime resolves to a row. The answer isn’t a code from a static option set (that’s single) — it’s a record with a primary-key value, a display label, and any number of named fields the asset carries.

TypeOptions live inAnswer modelPrimary accessor
lookupAsset — uploaded CSV or remote URLRetrieved record with named fields.value, .label, .field()

Properties split into Basic (what the majority of surveys need) and Advanced (large datasets, alias search, grouped lists). Most authors will only ever use Basic.

QPostcode lookup · searchInput

Enter a UK postcode.

Match must come from the postcode list.

EH1 1YZ
Edinburgh — Old Town
Scotland
EH3 9DR
Edinburgh — New Town
Scotland
G1 2AB
Glasgow — Merchant City
Scotland
M1 4AN
Manchester — City Centre
England
BT1 3LA
Belfast — Cathedral Quarter
Northern Ireland
project://uk_postcodes
Q.value—
Q.label—
Q.field("region")—
Q.matchedFalse

Type into the box and pick a row. The state panel shows what each accessor resolves to: Q.value is the primary key, Q.label is the display field, and Q.field("...") reads any named field off the matched record.

Skins

style controls the UI only. Data model, accessors, and storage are identical across all three styles.

StyleUIUse when
searchInput (default)Text input — results filter as the respondent typesLarge assets, or when the respondent is more likely to type than browse (ZIP, device model, diagnosis code).
dropdownSearchable dropdown — list is browseableSmaller assets where browsing is reasonable (states, vehicle makes).
cascadingSequential dependent stepsHierarchical selection — make then model, state then county then ZIP.

If style is omitted the renderer uses searchInput.

Basic properties

These six cover ZIP lookups, state / region mapping, make / model selection, device catalogues, and most other common patterns. Start here — only add Advanced properties for a specific reason.

PropertyValuesNotes
sourcehttp(s)://…The list-asset URL for single-step lookups — always the lookup REST server’s /lookup/<name> endpoint. Cascading uses per-step source: inside the steps: block instead — see below. The old project://name scheme still resolves for back-compat, but new YAML should emit plain URLs (project:// downloaded the whole list to the editor and never wired to the respondent — URL sources search server-side and keep the list private). global:// is a legacy alias for project:// and shouldn’t be used.
source.displaycolumn nameWhich column the respondent sees in the dropdown / search result. If omitted, the platform uses the first non-code column.
source.valuecolumn nameWhich column is stored as the primary answer (becomes Q.value). If omitted, the platform uses the column named code.
source.matchOnlyTrue | FalseWhen True, no list / dropdown is shown — the respondent types into a plain text field and the platform silently checks for a match. Q.matched returns the result. See matchOnly below.
source.levelintegerFor hierarchical assets only. 1 = top level (e.g. makes), 2 = second level (e.g. models). Omit for flat or grouped assets. Step-level only.
source.filterstep idCascading only. Filters this step’s source to records that belong to the named prior step’s resolved value. Reference the prior step by id only — no expression syntax here.
multiTrue | FalseDefault False. When True, the respondent can select multiple records. The selections render as chips above the input. Works with style: searchInput and style: dropdown; the validator rejects multi: True with style: cascading or with source.matchOnly: True. See Multi-select below.
min, maxintegerMulti-select only. Minimum / maximum number of records the respondent must / can select. max is enforced on click and on Q.add(...); min participates in the standard required-answer check.

The standard question shell properties also apply: qid, type, title, text, instruction, required, default.errors, validation, readonly, visibility, if, custom.

Basic examples

State select — returns region

- qid: QState
    type: lookup
    style: dropdown
    text: Which state are you based in?
    required: True
    source: https://lists.fieldbase.com/lookup/target_states
    source.display: name
    source.value: code

# Q.value  → "NY"
# Q.label  → "New York"

The asset has a region column but it isn’t declared in source.fields: — that’s an Advanced property. If you don’t need to route or export on region, you don’t need it.

Device model — searchable dropdown

- qid: QDevice
    type: lookup
    style: dropdown
    text: Which infusion pump model do you primarily use?
    required: True
    source: https://lists.fieldbase.com/lookup/infusion_device_models
    source.display: model_name
    source.value: model_code

# Q.value → "BD-AL-V3"
# Q.label → "Alaris 8015 PC Unit"
# Pipe:    "How satisfied are you with the {{ QDevice.label }}?"

source.matchOnly

Normally a lookup shows a list the respondent picks from. source.matchOnly: True changes this completely — no list is shown at all. The respondent sees a plain text input and types whatever they know. The platform silently checks whether their input matches a record in the asset. The respondent never knows whether a match was found.

The result is available via Q.matched: True if their input matched a record, False if not. Authors use this in routing to continue, screen out, or redirect.

When to use it

The classic case is ZIP code screening. The study targets specific ZIP codes; if you show a searchable dropdown, the respondent can see the full list of qualifying ZIPs — which reveals the geographic scope of the study and invites them to enter a fake ZIP they know will qualify. matchOnly keeps the validation invisible.

- qid: QZip
    type: lookup
    text: What is your ZIP code?
    instruction: Enter your 5-digit ZIP code.
    required: True
    source: https://lists.fieldbase.com/lookup/northeast_target_zips
    source.display: display_label
    source.value: zip
    source.matchOnly: True   # no dropdown — plain text input

# Route based on match result
- if: QZip.matched == False
    goto: QScreenout
Q.matched vs Q.answered. Q.answered is True as soon as the respondent enters any text and the platform finishes checking. Q.matched tells you whether that text found a record. A respondent can have Q.answered == True and Q.matched == False at the same time — they entered something, it just didn’t match.
When .matched resolves. The typed value is stored per keystroke, but the exact-match check runs once, on Next — the advance waits for it. That means .matched and .field(…) are always evaluated against a resolved value (no per-keystroke server chatter, no race), and the resolution is server-authoritative: the server checks the source list on submit, the client just sends the typed text. Bare-string answers no longer assume matched: True.

Other typical matchOnly patterns:

  • Study-specific NPI / license number — respondent enters their practitioner number; the platform validates against a private list without revealing the list.
  • Employee or customer ID — B2B panels where the client provides a list of qualifying IDs.
  • Product serial number — research where only owners of specific units should qualify.

Multi-select

multi: True flips the lookup from a single-record question into a multi-record one. The respondent can pick more than one row; each selection renders as a chip above the input, with a remove button on each chip.

QSpecialties lookup · multi · searchInput

Which conditions do you regularly treat?

Select up to 5.

No selections yet — type or scroll to add.
F32
Major Depressive Disorder Psychiatry
+
F41
Generalized Anxiety Disorder Psychiatry
+
I10
Essential Hypertension Cardiology
+
E11
Type 2 Diabetes Endocrinology
+
J45
Asthma Respiratory
+
M54
Back Pain Orthopaedics
+
K21
GERD Gastroenterology
+
project://medical_specialties
QSpecialties.size0
QSpecialties.answeredFalse
QSpecialties.values[]
QSpecialties.labels[]

Pick rows to add chips. Already-selected rows show a check and can’t be added again. Once you hit the max (5 here), the remaining rows dim out — clicks past the cap are silently dropped, matching the runtime’s .add() behaviour. The state panel below shows Q.size, Q.answered, Q.values, and Q.labels updating live.

StyleMulti-select supported?
searchInput✓ Type, pick a row, chip appears, search clears, type again.
dropdown✓ Pick a row, chip appears, dropdown stays at “Select…” — pick again.
cascading✗ Validator rejects (multi: True + cascading doesn’t combine).
searchInput + source.matchOnly: True✗ Validator rejects (matchOnly is a single-value text input).
- qid: QSpecialties
    type: lookup
    style: searchInput
    text: Which conditions do you regularly treat?
    multi: True
    min: 1
    max: 5
    source: https://lists.fieldbase.com/lookup/medical_specialties
    source.display: name
    source.value: code
    source.fields: therapeutic_area

min / max constrain the count of selections (not the value range). max is enforced when the respondent clicks a row and when a script calls Q.add(...); min is checked at submission time as part of the standard required-answer check.

Multi-select runtime API

The accessor and method surface flips when multi: True is set — single-lookup reads (.value, .label, .field(), .record, .matched) and writes (.set(...)) don’t apply. Use these instead:

ExpressionReturnsMeaning
Q.valuesStringListSelected value strings, in selection order.
Q.labelsStringListDisplay labels for each selected record.
Q.recordsObjectListFull records for each selection: [{ value, label, fields }, ...].
Q.sizeintCount of selected records.
Q.answeredboolTrue if at least one record is selected.
Q.notAnsweredboolInverse.
Q.add(value)—Append a record by value. Idempotent (no-op if already selected). Respects max: — a write that would exceed max is silently dropped. The added record is minimal (label mirrors value, fields empty); a respondent click resolves the full record.
Q.remove(value)—Remove the record with the given value.
Q.reset()—Clear all selections.
.set(…) doesn’t apply on multi-select. Use Q.add(value) and Q.remove(value) instead. The runtime treats multi: True as a separate parallel surface — the single-lookup writers and readers aren’t wired up to the multi storage.

Reading a multi-lookup field

Because each multi selection is a record (not just a value), you can read fields off any selected record by indexing into .records:

# In a script — every selected condition's therapeutic area
for r in QSpecialties.records:
    print(r.value, "→", r.fields["therapeutic_area"])

# Conditional on whether a specific code was picked
if "F32" in QSpecialties.values:
    show(QDepressionFollowup)

Cascading

When the respondent needs to make more than one linked selection — make then model, state then county — use style: cascading with a steps: block. Each step is a sub-lookup. A step can filter its source using any prior step’s resolved value: set source.filter to that step’s id. No other syntax needed.

The question counts as .answered only when every step has a resolved value. Later steps are visually dimmed and disabled until the step before them resolves; once it does, the next step unlocks and its options filter to the resolved parent value.

QVehicle lookup · cascading

What vehicle do you drive?

Select make, then model.

Make
Model — pick a make first
QVehicle.make.value—
QVehicle.make.label—
QVehicle.model.value—
QVehicle.model.label—
QVehicle.model.field("body")—
QVehicle.answeredFalse

Pick a make to unlock the Model step. The model dropdown filters to that make’s models, and the state panel shows each step resolving independently — QVehicle.make.value and QVehicle.model.value are read separately, while QVehicle.answered only flips to True once both steps have a value.

Shared source at the steps level. When all steps share the same source, display column, and value column, declare them once at the steps: header. Each step inherits these and only needs to specify what’s different — its id, label, source.filter, and source.level. A step that uses a different source can override any property locally.

Make / model — shared source, level overrides

- qid: QVehicle
    type: lookup
    style: cascading
    text: What vehicle do you drive?
    required: True
    steps:
        # Shared source — all steps inherit
        source: https://lists.fieldbase.com/lookup/vehicle_makes_models
        source.display: label
        source.value: code

        - id: make
            label: Select make
            source.level: 1
        - id: model
            label: Select model
            source.level: 2
            source.filter: make    # filter models to the resolved make

# QVehicle.make.value   → "BMW"
# QVehicle.model.value  → "3-SERIES"
# QVehicle.answered     → True only when both steps resolve

Country / region / city — three steps, each filters on the prior

- qid: QLocation
    type: lookup
    style: cascading
    text: Where are you located?
    required: True
    steps:
        source: https://lists.fieldbase.com/lookup/geo_hierarchy   # shared across all three steps
        source.display: name
        source.value: code

        - id: country
            label: Country
            source.level: 1
        - id: region
            label: Region
            source.filter: country
        - id: city
            label: City
            source.filter: region

Steps with different sources

Each step can override source entirely when it draws from a different asset.

- qid: QPractice
    type: lookup
    style: cascading
    text: Where is your practice located?
    required: True
    steps:
        - id: state
            label: State
            source: https://lists.fieldbase.com/lookup/target_states
            source.display: name
            source.value: code
        - id: zip
            label: ZIP code
            source: https://lists.fieldbase.com/lookup/northeast_target_zips   # different asset
            source.display: display_label
            source.value: zip
            source.filter: state
source.filter takes a step id only. It means “filter this step’s source to records that belong to the resolved value of that prior step.” A step can only filter on steps that appear earlier in the list. There is no expression syntax — just the step id.

Hidden lookup

Same type, same accessors, no UI. The value is set by a default: expression or by a script. The main use case is module version binding — assigning a design version to a respondent at interview start so a downstream conjoint or MaxDiff module knows which tasks to show.

- qid: hDesign
    type: lookup
    visibility: hide
    source: https://lists.fieldbase.com/lookup/maxdiff_designs
    source.display: label
    source.value: version_id
    default: latest_active   # platform resolves to current active design

# The module reads the version from the resolved lookup value:
- qid: QMaxDiff
    type: maxdiff
    design: hDesign.value

default: is only valid when visibility: hide.

Advanced properties

These extend the Basic set. Add them only when you have one of the specific use cases described below.

PropertyValuesWhen to use
source.fieldscomma-separated column names (or a single name)Pull extra columns from the matched record into storage. Needed when you want to route or pipe on a value the respondent didn’t explicitly select (e.g. region after a state pick). Each declared field becomes an export column.
source.searchFieldscomma-separated column names (or a single name)Index additional columns for search. Only needed when respondents might type something that doesn’t appear in the display label — an abbreviation, brand nickname, or code. Default is to search only source.display.
source.groupBycolumn nameFor dropdown only. Group entries under category headers using this column. Useful when the asset has a natural grouping (manufacturer, therapeutic area, product category).
source.minCharsintegerMinimum characters before search fires. Default 1 for dropdown, 2 for searchInput. Raise for very large assets (5k+ rows) to reduce unnecessary queries.

source.fields — exposing extra columns

Without source.fields, only Q.value and Q.label are available in scripts. The asset may have ten other columns; they’re not pulled into the response record unless declared here.

When you actually need it:

  • Routing on a field the respondent didn’t pick. After a state selection, you want to route based on region — without asking region as a separate question.
  • Text-piping a specific field. "You're based in {{ QState.field("region") }} — here are the questions for your area."
  • Exporting a second field. Each declared field becomes its own export column.
- qid: QState
    type: lookup
    style: dropdown
    text: Which state are you based in?
    source: https://lists.fieldbase.com/lookup/target_states
    source.display: name
    source.value: code
    source.fields: region, division   # pull these into the stored record

# QState.value             → "NY"
# QState.label             → "New York"
# QState.field("region")   → "Northeast"
# QState.field("division") → "Middle Atlantic"

- if: QState.field("region") == "Northeast"
    - qid: QNEFollowup
        type: single
        text: Which Northeast metro area are you closest to?
Only declare what you’ll use. Each field in source.fields is stored in the response and exported as its own column. Five declared, one used → the other four still appear in every respondent’s data file. Keep the list short.

source.searchFields — alias matching

By default the search index only covers source.display. If a respondent types something that doesn’t appear in the display label, the search returns nothing.

The classic case is medical device aliases. The display label might be "Alaris 8015 PC Unit", but a nurse might type "BD alaris", "alaris pump", or just "8015". None of those strings appear in the display label. If the asset has an aliases column containing those terms, adding it to source.searchFields matches all of them.

- qid: QDevice
    type: lookup
    style: searchInput
    text: Which infusion pump model do you primarily use?
    source: https://lists.fieldbase.com/lookup/infusion_device_models
    source.display: model_name
    source.value: model_code
    source.searchFields: model_name, manufacturer, aliases
    # Respondent types "bd alaris" → finds "Alaris 8015 PC Unit"
    # Without searchFields, "bd alaris" returns nothing
Search fields don’t change what’s shown. Only source.display appears in result rows. searchFields only affects what text gets matched when the respondent types — the matched aliases are never visible.

source.groupBy — categorised dropdown

Groups dropdown entries under visible category headers. The named column becomes the group label. Use it when the asset has a natural grouping and respondents orient faster from a categorised list than a flat alphabetical one.

- qid: QDevice
    type: lookup
    style: dropdown
    text: Which infusion pump model do you primarily use?
    source: https://lists.fieldbase.com/lookup/infusion_device_models
    source.display: model_name
    source.value: model_code
    source.groupBy: manufacturer
    # Renders: BD header → BD models, ICU Medical header → ICU models, …

Methods & accessors

The accessor surface depends on whether the lookup is single-record (default) or multi-record (multi: True). The table below covers the single-record surface; for the multi surface, see Multi-select runtime API.

Single-step / question-level

ExpressionReturnsMeaning
Q.valuestrPrimary stored value (the source.value column). What gets exported as the question’s column.
Q.labelLabelDisplay label of the resolved record (the source.display column).
Q.field("name")str | NoneNamed field from source.fields. None if the field wasn’t declared.
Q.recordobjectFull matched record — for scripts that need many fields at once.
Q.matchedboolTrue if the stored record came from a confirmed match against the source. For matchOnly, this is the result of the silent check. False while unanswered or when the typed value didn’t match a row.
Q.answeredboolTrue once all required steps have a resolved value.
Q.notAnsweredboolInverse.

Cascading step proxy

Reference each step by its id directly on the question — no prefix needed.

ExpressionReturnsMeaning
Q.stepId.valuestrPrimary value at that step.
Q.stepId.labelLabelDisplay label at that step.
Q.stepId.field("name")str | NoneNamed field from that step’s record.
Q.stepId.recordobjectFull record for that step.
Q.stepId.answeredboolTrue if that step has a resolved value.
Q.stepId.notAnsweredboolInverse.

Methods

ExpressionMeaning
Q.set(value)Set the primary value programmatically. Writes a minimal record (value + label mirrored from the argument; field("...") reads return empty). The runtime does not currently re-resolve the row from the source asset, so values that depend on source.fields won’t be populated by set — only by an actual respondent selection.
Q.set(stepId, value)Cascading only. Set a single step’s value. Same minimal-record behaviour as the single-step form — does not currently cascade-clear later steps that filter on stepId, so reset those steps explicitly if you need to.
Q.reset()Clear the answer (all steps for cascading).
Q.reset(stepId)Cascading only. Clear the named step. Later steps that filter on it are not currently cascade-cleared — call Q.reset(...) for each step you want to clear.
No collection APIs on lookup. There’s no .any(), .intersect(), or .selected — those belong to single / multi. Seeing .field() and .value on a question tells you immediately it’s a lookup.

Routing examples

# matchOnly ZIP screenout
- if: QZip.matched == False
    goto: QScreenout

# Route on a retrieved field (requires source.fields declared)
- if: QState.field("region") == "Northeast"
    - qid: QNEFollowup
        type: single
        text: Which Northeast metro are you closest to?

# Route on whether a step is answered (cascading)
- qid: QYears
    type: number
    text: How many years have you driven a {{ QVehicle.make.label }}?
    if: QVehicle.make.answered

# Text piping
text: How satisfied are you with the {{ QDevice.label }}?
text: You drive a {{ QVehicle.make.label }} {{ QVehicle.model.label }}. Is that your primary?

Cascading step activation

In a cascading lookup, later steps activate automatically when the prior step resolves. On mobile the respondent can’t advance past an incomplete step; on desktop, incomplete steps are visually dimmed.

Export

ColumnPatternExample
Single-step primaryQidQZip = "10001"
Single-step fieldQidFieldNameQZipCity, QZipState, QZipRegion
Cascading step primaryQidStepIdQVehicleMake, QVehicleModel
Cascading step fieldQidStepIdFieldNameQVehicleModelBodyType
matchOnly primaryQidQZip = "10001" or null if no match

Asset field names are converted to camelCase in the export column: body_type → BodyType, display_label → DisplayLabel. This keeps export column names alphanumeric without underscores (except the loop suffix).

Validation rules

  • steps is required when style: cascading. The validator rejects a cascading lookup with no steps: block.
  • source.filter must reference a step id defined earlier in the same steps list. Any other value is a parse error.
  • Step ids must be unique within a question. Duplicates are a parse error.
  • multi: True is rejected on style: cascading. Cascading produces a single stepped selection, not a list.
  • multi: True is rejected when source.matchOnly: True. matchOnly is a single-value text-input mode.

A few things are convention rather than enforced:

  • A single-step lookup needs a source: to be useful, but the validator doesn’t currently reject the question if source: is missing — it’ll just render with nothing to query.
  • source.groupBy only renders under style: dropdown — it’s silently ignored on the other styles.
lookup is not a valid mixGrid child type. Even though some early drafts listed it, the current renderer doesn’t support a lookup column inside mixGrid.columns. Use a separate lookup question outside the grid instead.

See also