Lookup Fields
Create dropdown fields that fetch options from another MongoDB collection. Enable cascading lookups for dependent selections.
Configurationโ
When configuring a lookup field, you need to specify:
- Collection - The source collection to fetch options from
- Display Field - Which field to show in the dropdown (e.g., "name")
- Value Field - Which field to store as the value (e.g., "_id")
- Searchable - Enable autocomplete search
- Multiple - Allow selecting multiple values
Basic Lookup Exampleโ
To create a lookup that references a customers collection:
- Add a Lookup field type to your form
- Set Collection to
customers - Set Display Field to
name - Set Value Field to
_id - Enable Searchable if the collection is large
The dropdown will show customer names, but store the customer _id in your document.
Cascading Lookupsโ
Create dependent dropdowns where the options in one field are filtered based on another field's selection.
Example: Country โ Stateโ
First, select a Country, then the State dropdown shows only states from that country.
Configuration Steps:
-
Create a Country lookup field
- Collection:
countries - Display Field:
name - Value Field:
_id
- Collection:
-
Create a State lookup field
- Collection:
states - Display Field:
name - Value Field:
_id - Filter Field:
countryId - Filter Source: Point to the Country field
- Collection:
When a country is selected, the State lookup automatically filters to show only states where countryId matches the selected country.
Filter Optionsโ
Static Filtersโ
Filter lookup options with a static query:
{
"status": "active",
"type": "customer"
}
Dynamic Filtersโ
Filter based on other form field values:
- Reference current form values
- Update options when dependencies change
- Chain multiple cascading lookups
Advanced Optionsโ
Searchable Lookupsโ
Enable search for large collections:
- Users can type to filter options
- Server-side search for performance
- Debounced search requests
Multiple Selectionโ
Allow selecting multiple values:
- Stores as array in MongoDB
- Tag-style display
- Min/max selection limits
Custom Displayโ
Customize how options appear:
- Combine multiple fields for display
- Format values (currency, dates)
- Add icons or badges
For large collections, enable "Searchable" to let users type and filter options instead of loading all values upfront.
Use Casesโ
- Customer Selection - Pick from existing customers
- Category Assignment - Assign categories from a list
- User Assignment - Assign tasks to team members
- Product Selection - Select products for an order
- Location Hierarchy - Country โ State โ City
Best Practicesโ
- Index lookup fields - Ensure MongoDB indexes on queried fields
- Limit results - Don't load thousands of options at once
- Enable search - For collections with many documents
- Use meaningful displays - Show names, not IDs
- Consider performance - Use pagination for large datasets
Next Stepsโ
- Field Configuration - Configure other field properties
- Computed Fields - Calculate values from lookups
- Conditional Logic - Show fields based on lookup values