# CodeCop Warning AA0231
StrSubstNo or string concatenation must not be used as a parameter in the Error method.
## Description
The data classification context will be lost when using the StrSubstNo method or string concatenation as a parameter in the Error method. Instead use the ability of the Error method to insert values into the string with placeholders.
## Reason for the rule
All error messages are logged into telemetry and we do not allow adding customer data into telemetry. So, all errors that have a textconst as the first argument actually log the textconst in telemetry, this greatly increases the ability to resolve errors found in telemetry. If StrSubstNo or string concatenation is used as first argument the data classification context is lost and no message text is logged in telemetry.
## Bad code example
```al
var
   ErrorMsg: Label 'Customer %1 has incorrect email', Comment = '%1 = Customer No.';

local procedure MyProcedure()
begin
    Error(StrSubstNo(ErrorMsg, Customer."No.");
end;
```
```al
var
   Text000Err: Label 'There are no planning lines to make orders for. ';
   Text007Err: Label 'This template and worksheet are currently active. ';
local procedure MyProcedure()
begin
    Error(Text000Err + Text007Err);
end;
```
## Good code example
```al
var
    ErrorMsg: Label 'Customer %1 has incorrect email', Comment = '%1 = Customer No.';
local procedure MyProcedure()
begin
    Error(ErrorMsg, Customer."No.");

end;
```
```al
var
   ErrorMsg: Label 'There are no planning lines to make orders for. This template and worksheet are currently active. ';
local procedure MyProcedure()
begin
    Error(ErrorMsg);
end;
```
## Good and bad practices for fixing the rule
Use the ability of the ../methods-auto/dialog/dialog-error-errorinfo-method method to insert values (expressions) into the string that has a placeholder.
## Related information
CodeCop Analyzer<codecop>
Get Started with AL<../devenv-get-started>
Developing Extensions<../devenv-dev-overview>

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/analyzers/codecop-aa0231, 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. https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/codecop-aa0231/
