{"title":"OnValidate (Page Field) trigger","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/pagefield/devenv-onvalidate-pagefield-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/pagefield/devenv-onvalidate-pagefield-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/pagefield/devenv-onvalidate-pagefield-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 field loses focus after its value has been changed.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"OnValidate (Page Field) trigger","slug":"onvalidate-page-field-trigger","at":0,"chars":1408},{"level":2,"title":"Syntax","slug":"syntax","at":158,"chars":60},{"level":2,"title":"Remarks","slug":"remarks","at":218,"chars":750},{"level":2,"title":"Example","slug":"example","at":968,"chars":282},{"level":2,"title":"Related information","slug":"related-information","at":1250,"chars":158}],"text":"# OnValidate (Page Field) trigger\n> Version: _Available or changed with runtime version 1.0._\nRuns when a field loses focus after its value has been changed.\n## Syntax\n```al\ntrigger OnValidate()\nbegin\n    ...\nend;\n```\n## Remarks\nThis trigger is run after the default validation behavior when data is entered in a field. During the default validation behavior, the system checks that the data type of the value entered matches the one defined for the field and that it complies with the property constraints set up in such field before the validation occurs. 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.\nThe OnValidate trigger is also a field trigger at the page level. See ../field/devenv-onvalidate-field-trigger. If both the table field and page field triggers are defined, then the OnValidate trigger on the table field is run before the OnValidate trigger on the page field.\n## Example\n```al\ntableextension 50111 \"CustomerExt\" extends Customer\n{\n    fields\n    {\n        field(50112; Acronym; Text[15])\n        {\n            trigger OnValidate()\n            begin\n                rec.Acronym := rec.Acronym.ToUpper();\n            end;\n        }\n    }\n}\n```\n## Related information\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>\n../field/devenv-onvalidate-field-trigger"}