{"title":"OnBeforeValidate (Field Extension) trigger","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/fieldextension/devenv-onbeforevalidate-fieldextension-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/fieldextension/devenv-onbeforevalidate-fieldextension-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/fieldextension/devenv-onbeforevalidate-fieldextension-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 before the user input is validated.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"OnBeforeValidate (Field Extension) trigger","slug":"onbeforevalidate-field-extension-trigger","at":0,"chars":1198},{"level":2,"title":"Syntax","slug":"syntax","at":146,"chars":66},{"level":2,"title":"Remarks","slug":"remarks","at":212,"chars":390},{"level":2,"title":"Example","slug":"example","at":602,"chars":357},{"level":2,"title":"Related information","slug":"related-information","at":959,"chars":239}],"text":"# OnBeforeValidate (Field Extension) trigger\n> Version: _Available or changed with runtime version 1.0._\nRuns before the user input is validated.\n## Syntax\n```al\ntrigger OnBeforeValidate()\nbegin\n    ...\nend;\n```\n## Remarks\nThis trigger is run before the default validation behavior is executed on a record field entry, which are default checks such as data type validation. An error message displays if an error occurs in the trigger code. In case of an error, the user entry is not written to the database.\nIt applies to an already existing table field when it is being modified in a table extension.\n## Example\n```al\ntableextension 50111 \"CustomerExt\" extends Customer\n{\n    fields\n    {\n        modify(\"Address 2\")\n        {\n            trigger OnBeforeValidate()\n            begin\n                if (rec.Address = '') then\n                    error('Please, input a first address before specifying a second one.');\n            end;\n        }\n    }\n}\n```\n## Related information\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>\nOnBeforeValidate (Page Field Extension) Trigger<../pagefieldextension/devenv-onbeforevalidate-pagefieldextension-trigger>"}