# OnLookup (Page Field Extension) trigger
> Version: _Available or changed with runtime version 3.0._
Runs in place of the normal lookup features for the current page.
## Syntax
```al
trigger OnLookup(var Text: Text): Ok
begin
    ...
end;
```
### Parameters
Text
Type: ../../methods-auto/text/text-data-type
Specifies a text string entered into the text box and used as the lookup value.
## Return value
Ok
Type: ../../methods-auto/boolean/boolean-data-type
true if the lookup was carried out, otherwise, false.
## Remarks
There are three lookup options:
 Default Lookup - The lookup into the table is performed without applying filters or other special parameters.
 Field Lookup - You can define a lookup trigger on a field that will be used in place of the default lookup. See ../field/devenv-onlookup-field-trigger.
 Text box Lookup - You can use this 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.
For example, for the Customer Code field, a lookup into the Customer table is provided. If you want a lookup into another table or if you want to place a filter on the table before displaying the lookup, use this trigger.
If an error occurs in the trigger code, the lookup is canceled.
You can use this trigger to write to the database.
> NOTE
> If you have defined an OnLookup trigger, the ../pagefield/devenv-onafterlookup-pagefield-trigger will not be fired.
> NOTE
> OnLookup is also a field trigger at the table level. The flow is different for this trigger. When a lookup is requested, the page field's OnLookup trigger is executed if it is defined in the field lookup or system default. If no control lookup trigger is defined, the ../field/devenv-onlookup-field-trigger \(if defined\) replaces the system default lookup.
## Related information
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>
../field/devenv-onlookup-field-trigger
OnLookup (Page Field) Trigger<../pagefield/devenv-onlookup-pagefield-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/pagefieldextension/devenv-onlookup-pagefieldextension-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/pagefieldextension/devenv-onlookup-pagefieldextension-trigger/
