SetRange with filter operators (PC0003)
The SetRange method expects exact values, not filter expressions. If you pass a string containing filter operators (like *, .., |) to SetRange, they will be treated as literal characters, not as wildcards or operators.
Use SetFilter instead when you need to apply filter expressions with operators.
A code fix is available for this diagnostic.
Example
The following code incorrectly uses SetRange with a filter expression:
codeunit 50100 MyCodeunit
{
procedure FindCustomers()
var
Customer: Record Customer;
begin
Customer.SetRange(Name, 'A*'); // SetRange with filter operators [PC0003]
Customer.FindSet();
end;
}
To fix this, use SetFilter for filter expressions:
codeunit 50100 MyCodeunit
{
procedure FindCustomers()
var
Customer: Record Customer;
begin
Customer.SetFilter(Name, 'A*');
Customer.FindSet();
end;
}