# OnLookup (Field) trigger
> Version: _Available or changed with runtime version 1.0._
Runs when a lookup page is displayed.
## Syntax
```al
trigger OnLookup()
begin
    ...
end;
```
## Remarks
The ../../properties/devenv-lookup-property must be set to True to enable the lookup.
There are three lookup options:
1. Default Lookup - The lookup into the table is performed without applying filters or other special parameters.
2. Field Lookup - You can use this trigger to define a field lookup that will be used in place of the default lookup.
3. Text box Lookup - You can use the OnLookup \(Page fields\) Trigger<../pagefield/devenv-onlookup-pagefield-trigger> to define a lookup based on the value of a text box. This value will be used in place of the default lookup or the field lookup.
When using this trigger, follow this approach:
 Use the field value to determine what filters or other parameters to apply.
 Run the lookup page as a modal page.
 Transfer the value the user selects back to the field when the user chooses OK.
  If an error occurs in the trigger code, the lookup page is closed.
> NOTE
> The lookup for a non-editable field is not rendered. You can use the ../pagefield/devenv-ondrilldown-pagefield-trigger instead.
## Related information
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>
OnLookup (Page Field) Trigger<../pagefield/devenv-onlookup-pagefield-trigger>
OnLookup (Page Field Extension) Trigger<../pagefieldextension/devenv-onlookup-pagefieldextension-trigger>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/triggers-auto/field/devenv-onlookup-field-trigger, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/field/devenv-onlookup-field-trigger/
