How to Set Up a Custom Lookup
A Custom Lookup lets you point a custom field at an existing Business Central table so that users can search and select from real data rather than a manually maintained list of values. For example, you could point a custom Code field on a Sales Line to the Location table, so users always pick from valid locations.
Before You Start
- The custom field must already be defined on the Custom Fields Definitions page.
- Custom Lookups only apply to Code and Text field types.
- Make sure the field type of the lookup field in Business Central matches the type of your custom field. Mismatched types can cause runtime errors.
Steps
1. Open the Custom Lookup Page
- Choose the
icon, enter Custom Fields Definitions, and choose the related link. - Select the custom field you want to configure a lookup for.
- Choose the Custom Lookup action in the ribbon.
2. Configure the Lookup Table and Field
On the Custom Fields Lookup page:
- In Custom Lookup Table, enter or select the Business Central table number you want to use as the lookup source (for example, 14 for Location, 18 for Customer).
- In Custom Lookup Field, select the field from that table whose value will be stored in and displayed from the custom field.
- Optionally, in Custom Lookup Page, select the page to open when the user clicks the lookup button. If left blank, Business Central uses the default lookup page for the table where one exists.
Warning
The data type of the Custom Lookup Field must match the type of your custom field. For example, a custom Code(20) field requires a lookup field that is also Code(20) or shorter.
3. Add Filters (Optional)
Once the lookup table and field are set, the Custom Filters section at the bottom of the page becomes available. Filters limit which records appear in the lookup list.
For each filter row:
- Set Source Field No. to the field from the lookup table you want to filter on.
- Set Relation Type:
- Choose Filter to apply a fixed, constant value.
- Choose Field to filter dynamically based on a field value from the current record.
- If Relation Type is Filter, enter the constant value in Value.
- If Relation Type is Field, select the matching field from the lookup table in Filter Field No..
You can add multiple filter rows. All filter rows are applied together (AND logic).
4. Test the Lookup
Close the setup page. Navigate to a record that uses the custom field (for example, a Sales Order line if you defined the field on Sales Line) and click the lookup button next to the custom field. The lookup should open showing only the filtered records from the configured table.
Example: Limit a Custom Field to Active Items Only
Suppose you have a custom Code field on Sales Header and want it to look up only non-blocked customers:
- Set Custom Lookup Table to 18 (Customer).
- Set Custom Lookup Field to No. (the customer number).
- Set Custom Lookup Page to 22 (Customer List).
- In the filters section, add a row:
- Source Field No.: 39 (Blocked)
- Relation Type: Filter
- Value: leave blank (meaning "not blocked")