BCQuality rule · styleAL Developmentofficial - Microsoftderived - from the source, no model text

Pass parameters directly to `Error()`, do not wrap with `StrSubstNo`

Error() accepts a format string and a variable number of arguments — Error(SomeLabelErr, Arg1, Arg2). The platform performs the substitution itself, which is the path the translation pipeline understands.

Rule on GitHub · microsoft layer · style · BC all · tier official · derived

Description

Error() accepts a format string and a variable number of arguments — Error(SomeLabelErr, Arg1, Arg2). The platform performs the substitution itself, which is the path the translation pipeline understands. Wrapping the same call as Error(StrSubstNo(SomeLabelErr, Arg1, Arg2)) hides the placeholders from the platform and removes the format-string identity from the call-site, so analyzers cannot match the call to its label and translators lose the link between the formatted message and its template. The corresponding anti-pattern for hardcoded strings — Error('Customer ' + CustomerNo + ' not found') — is even worse: it builds an untranslatable, unanalyzable string at runtime.

Best Practice

Declare a Label with the Err suffix and the appropriate Comment for placeholders, then call Error(YourErr, arg1, arg2). The same rule applies to Message, Confirm, and other UI primitives: format string in, parameters as separate arguments, no StrSubstNo wrapper at the call site, no string concatenation. An Error('') (empty message) is acceptable when the calling code expects another layer to emit the actual diagnostic.

See sample: error-passes-parameters-directly-not-strsubstno.good.al.

Anti Pattern

Error(StrSubstNo(CustomerNotFoundErr, CustomerNo)) and Error(CustomerNotFoundErr + ': ' + CustomerNo) both defeat the translation and analysis machinery. Reviewers should treat StrSubstNo appearing as an argument to Error, Message, Confirm, or StrMenu as an unconditional signal to rewrite.

See sample: error-passes-parameters-directly-not-strsubstno.bad.al.

Examples

Names

Changed by


From microsoft/BCQuality at a4593a1, MIT License, Copyright (c) 2026 Microsoft Corporation (license).