{"title":"OnLookup (Page Field Extension) trigger","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/pagefieldextension/devenv-onlookup-pagefieldextension-trigger/","by":"JOP-AL","license":"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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/triggers-auto/pagefieldextension/devenv-onlookup-pagefieldextension-trigger","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Runs in place of the normal lookup features for the current page.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"OnLookup (Page Field Extension) trigger","slug":"onlookup-page-field-extension-trigger","at":0,"chars":2056},{"level":2,"title":"Syntax","slug":"syntax","at":168,"chars":221},{"level":3,"title":"Parameters","slug":"parameters","at":244,"chars":145},{"level":2,"title":"Return value","slug":"return-value","at":389,"chars":124},{"level":2,"title":"Remarks","slug":"remarks","at":513,"chars":1309},{"level":2,"title":"Related information","slug":"related-information","at":1822,"chars":234}],"text":"# OnLookup (Page Field Extension) trigger\n> Version: _Available or changed with runtime version 3.0._\nRuns in place of the normal lookup features for the current page.\n## Syntax\n```al\ntrigger OnLookup(var Text: Text): Ok\nbegin\n    ...\nend;\n```\n### Parameters\nText\nType: ../../methods-auto/text/text-data-type\nSpecifies a text string entered into the text box and used as the lookup value.\n## Return value\nOk\nType: ../../methods-auto/boolean/boolean-data-type\ntrue if the lookup was carried out, otherwise, false.\n## Remarks\nThere are three lookup options:\n Default Lookup - The lookup into the table is performed without applying filters or other special parameters.\n 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.\n 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.\nFor 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.\nIf an error occurs in the trigger code, the lookup is canceled.\nYou can use this trigger to write to the database.\n> NOTE\n> If you have defined an OnLookup trigger, the ../pagefield/devenv-onafterlookup-pagefield-trigger will not be fired.\n> NOTE\n> 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.\n## Related information\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>\n../field/devenv-onlookup-field-trigger\nOnLookup (Page Field) Trigger<../pagefield/devenv-onlookup-pagefield-trigger>"}