{"title":"OnLookup (Field) trigger","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/field/devenv-onlookup-field-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/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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/triggers-auto/field/devenv-onlookup-field-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 when a lookup page is displayed.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":98,"chars":58},{"level":2,"title":"Remarks","slug":"remarks","at":156,"chars":1056},{"level":2,"title":"Related information","slug":"related-information","at":1212,"chars":301}],"text":"> Version: _Available or changed with runtime version 1.0._\nRuns when a lookup page is displayed.\n## Syntax\n```al\ntrigger OnLookup()\nbegin\n    ...\nend;\n```\n## Remarks\nThe ../../properties/devenv-lookup-property must be set to True to enable the lookup.\nThere are three lookup options:\n1. Default Lookup - The lookup into the table is performed without applying filters or other special parameters.\n2. Field Lookup - You can use this trigger to define a field lookup that will be used in place of the default lookup.\n3. 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.\nWhen using this trigger, follow this approach:\n Use the field value to determine what filters or other parameters to apply.\n Run the lookup page as a modal page.\n Transfer the value the user selects back to the field when the user chooses OK.\n  If an error occurs in the trigger code, the lookup page is closed.\n> NOTE\n> The lookup for a non-editable field is not rendered. You can use the ../pagefield/devenv-ondrilldown-pagefield-trigger instead.\n## Related information\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>\nOnLookup (Page Field) Trigger<../pagefield/devenv-onlookup-pagefield-trigger>\nOnLookup (Page Field Extension) Trigger<../pagefieldextension/devenv-onlookup-pagefieldextension-trigger>"}