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.
| Type | Options live in | Answer model | Primary accessor |
|---|---|---|---|
lookup | Asset — uploaded CSV or remote URL | Retrieved 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.
Enter a UK postcode.
Match must come from the postcode list.
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.
| Style | UI | Use when |
|---|---|---|
searchInput (default) | Text input — results filter as the respondent types | Large assets, or when the respondent is more likely to type than browse (ZIP, device model, diagnosis code). |
dropdown | Searchable dropdown — list is browseable | Smaller assets where browsing is reasonable (states, vehicle makes). |
cascading | Sequential dependent steps | Hierarchical 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.
| Property | Values | Notes |
|---|---|---|
source | http(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.display | column name | Which column the respondent sees in the dropdown / search result. If omitted, the platform uses the first non-code column. |
source.value | column name | Which column is stored as the primary answer (becomes Q.value). If omitted, the platform uses the column named code. |
source.matchOnly | True | False | When 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.level | integer | For 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.filter | step id | Cascading 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. |
multi | True | False | Default 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, max | integer | Multi-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..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.
Which conditions do you regularly treat?
Select up to 5.
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.
| Style | Multi-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:
| Expression | Returns | Meaning |
|---|---|---|
Q.values | StringList | Selected value strings, in selection order. |
Q.labels | StringList | Display labels for each selected record. |
Q.records | ObjectList | Full records for each selection: [{ value, label, fields }, ...]. |
Q.size | int | Count of selected records. |
Q.answered | bool | True if at least one record is selected. |
Q.notAnswered | bool | Inverse. |
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.
What vehicle do you drive?
Select make, then model.
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.
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.
| Property | Values | When to use |
|---|---|---|
source.fields | comma-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.searchFields | comma-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.groupBy | column name | For dropdown only. Group entries under category headers using this column. Useful when the asset has a natural grouping (manufacturer, therapeutic area, product category). |
source.minChars | integer | Minimum 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?
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
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
| Expression | Returns | Meaning |
|---|---|---|
Q.value | str | Primary stored value (the source.value column). What gets exported as the question’s column. |
Q.label | Label | Display label of the resolved record (the source.display column). |
Q.field("name") | str | None | Named field from source.fields. None if the field wasn’t declared. |
Q.record | object | Full matched record — for scripts that need many fields at once. |
Q.matched | bool | True 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.answered | bool | True once all required steps have a resolved value. |
Q.notAnswered | bool | Inverse. |
Cascading step proxy
Reference each step by its id directly on the question — no
prefix needed.
| Expression | Returns | Meaning |
|---|---|---|
Q.stepId.value | str | Primary value at that step. |
Q.stepId.label | Label | Display label at that step. |
Q.stepId.field("name") | str | None | Named field from that step’s record. |
Q.stepId.record | object | Full record for that step. |
Q.stepId.answered | bool | True if that step has a resolved value. |
Q.stepId.notAnswered | bool | Inverse. |
Methods
| Expression | Meaning |
|---|---|
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. |
.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
| Column | Pattern | Example |
|---|---|---|
| Single-step primary | Qid | QZip = "10001" |
| Single-step field | QidFieldName | QZipCity, QZipState, QZipRegion |
| Cascading step primary | QidStepId | QVehicleMake, QVehicleModel |
| Cascading step field | QidStepIdFieldName | QVehicleModelBodyType |
matchOnly primary | Qid | QZip = "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
stepsis required whenstyle: cascading. The validator rejects a cascading lookup with nosteps:block.source.filtermust reference a step id defined earlier in the samestepslist. Any other value is a parse error.- Step ids must be unique within a question. Duplicates are a parse error.
multi: Trueis rejected onstyle: cascading. Cascading produces a single stepped selection, not a list.multi: Trueis rejected whensource.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 ifsource:is missing — it’ll just render with nothing to query. source.groupByonly renders understyle: dropdown— it’s silently ignored on the other styles.
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
- single — inline option list, no external asset.
- Authoring workflow — uploading source assets.
- Piping —
{{ Q.field("...") }}in question text. - Question proxies — accessor surface and cascading step proxies.