Avoid unsupported operators with placeholders in SetFilter expressions

Properties
PC0008 Error Design Code Fix Ignore Obsolete

SetFilter supports placeholder substitution (%1, %2, …) in its filter expression. However, when the filter string also contains a *, ?, or @ operator, the placeholder is not substituted. The literal text %1 becomes part of the filter, and the query silently returns the wrong records or none at all.

Wrap the filter expression in StrSubstNo() to resolve placeholders before passing the result to SetFilter.

Example

procedure FindCustomerByVAT(VATNo: Text)
var
    Customer: Record Customer;
begin
    Customer.SetFilter("VAT Registration No.", '*%1*', VATNo); // Avoid unsupported operators with placeholders in SetFilter expressions [PC0008]
end;

Use StrSubstNo() to substitute the placeholder first:

procedure FindCustomerByVAT(VATNo: Text)
var
    Customer: Record Customer;
begin
    Customer.SetFilter("VAT Registration No.", StrSubstNo('*%1*', VATNo));
end;