community postAL Developmentcommunity - not Microsoftreviewed - checked by Opus

Dynamics 365 Business Central: Regarding the default field name/table name in the error message thrown by Record.TestField Method

The Record.TestField Method in Business Central automatically generates error messages when field validation fails, but customizing field or table captions through TableExtension will affect these error messages. PageExtension modifications do not affect TestField error messages since the method uses standard table and field captions.

post Dynamics 365 Lab

Yun Zhu · 2025-07-31 · 425 words · about 2 min

"Record.TestField(Any) Method: Tests that the content of the field is not zero or blank (empty string)."

Key points

  • Record.TestField Method validates that a field is not empty or zero and automatically generates user-friendly error messages without custom code.
  • TableExtension modifications to field or table captions are reflected in TestField error messages, potentially affecting standard error display.
  • PageExtension modifications to captions do not affect TestField error messages because the method uses standard captions from the table definition.
  • When calling TestField without an ErrorInfo object, Business Central automatically creates navigation links to relevant card pages for error correction.
  • Navigation links are not generated if the error occurs on the currently open page or if the user lacks permissions to modify the record.

Quotes

  • “Record.TestField(Any) Method: Tests that the content of the field is not zero or blank (empty string).” (Explains the core validation functionality that developers rely on for field validation without custom error code.)
  • “If you use TableExtension to modify the captions of tables and fields, it will also affect the Record.TestField Method.” (Critical distinction showing that TableExtension changes impact standard error messages, unlike PageExtension modifications.)

AL objects mentioned

As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.

  • other “Record.TestField Method”

Heads up

  • gotcha: “if you use TableExtension to modify the captions of tables and fields, it will also affect the Record.TestField Method”

Context

  • Features: Field validation with TestField, Automatic error message generation, TableExtension caption customization, PageExtension modification, Error information object, Navigation links to correction pages
  • Versions: 2024 wave 1

Source: Dynamics 365 Lab - Yun Zhu, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.