---
title: Lookup definition
description: Return fields and records for search and options inputs.
---

Register a lookup with `resource.lookup(name, resolver)` or
`resource.lookup(name, { params }, resolver)`. A name must be unique within
its resource. The resolver receives `ctx` and a `LookupBuilder`.

<BacklitExample path="targets/lookup/params" view="create" />

Read search text from `ctx.searchQuery` and parameters from `ctx.paramValues`.
Return `lookup.setFields(fields).withData(rows)`. Use `setRoles(map)` to select
field roles and `onDefect(reporter)` to handle invalid values. The default role
is `display`. Extra record keys do not travel in the response.

The SDK does not query your data store or filter records automatically.
A search input sends the typed query. An options input sends an empty query.
The host calls `app.handleLookup(resource, name, query, args)` for both.

Use `lookupVia` or `optionsVia` to connect an input to the definition. Both
check the selected `value` and `label` field names. Supply an argument for
every parameter. Field arguments read the current form or repeater row.
See [Lookup targets](/reference/targets/lookup).

The definition exposes `resource`, `name`, and `params`. Its `resolve(ctx)`
method returns a success response containing the lookup fields and data.
Use the app method when middleware and address checks must run.
