{"title":"Record.TestField(Any, Any) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/record/record-testfield-joker-joker-method/","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/methods-auto/record/record-testfield-joker-joker-method, 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/methods-auto/record/record-testfield-joker-joker-method","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":"Tests whether the contents of a field match a given value.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Record.TestField(Any, Any) Method","slug":"recordtestfieldany-any-method","at":0,"chars":2026},{"level":2,"title":"Syntax","slug":"syntax","at":155,"chars":62},{"level":2,"title":"Parameters","slug":"parameters","at":217,"chars":539},{"level":2,"title":"Remarks","slug":"remarks","at":756,"chars":1136},{"level":2,"title":"Related information","slug":"related-information","at":1892,"chars":134}],"text":"# Record.TestField(Any, Any) Method\n> Version: _Available or changed with runtime version 1.0._\nTests whether the contents of a field match a given value.\n## Syntax\n```al\n Record.TestField(Field: Any, Value: Any)\n```\n## Parameters\nRecord\nType: record-data-type\nAn instance of the record-data-type data type.\nField\nType: ../any/any-data-type\nThe field that you want to test.\nValue\nType: ../any/any-data-type\nThe value that you want to compare to Field. The data type of this parameter must match the data type of Field. If you include this optional parameter and the contents of Field do not match, then an error message is displayed. If you omit this parameter and the contents of Field is zero or blank (empty string), then an error message is displayed.\n## Remarks\nUnlike the single-parameter TestField(Field)<record-testfield-joker-method> overload, this two-parameter overload doesn't automatically add a Show [Record] navigation button to the error dialog. When `TestField(Field, Value)` fails, it displays a plain error message (for example, \"Status must be equal to 'Certified' in Routing Header...\") with only an OK button.\nThis behavioral difference is by design: the single-parameter overload checks for a non-empty/non-zero value, and the platform knows the fix is \"go fill in the field on the record.\" The two-parameter overload checks for a specific value, and the platform can't assume which page or action would resolve the mismatch.\nIf you want the error dialog to include navigation to a related record, use the TestField(Field, Value, ErrorInfo)<record-testfield-joker-joker-errorinfo-method> overload and configure the ../errorinfo/errorinfo-data-type object with the appropriate ../errorinfo/errorinfo-pageno-method and ../errorinfo/errorinfo-recordid-method. You can also add a ../errorinfo/errorinfo-fieldno-method to highlight the specific field that needs correction.\n## Related information\nrecord-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}