{"title":"OnValidate (Field) trigger","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/field/devenv-onvalidate-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-onvalidate-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-onvalidate-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 user input is validated.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":95,"chars":60},{"level":2,"title":"Remarks","slug":"remarks","at":155,"chars":792},{"level":2,"title":"Example","slug":"example","at":947,"chars":282},{"level":2,"title":"Related information","slug":"related-information","at":1229,"chars":199}],"text":"> Version: _Available or changed with runtime version 1.0._\nRuns when user input is validated.\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 OnValidate (Page Fields) Trigger<../pagefield/devenv-onvalidate-pagefield-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>\nOnValidate (Page Field) Trigger<../pagefield/devenv-onvalidate-pagefield-trigger>"}