Invalid single-quote escaping in filter string
Many AL developers attempt to set an is not empty filter by writing '<>''' as the filter expression. The intention is <>'' (not equal to the empty string), but the quote escaping produces a different value.
In AL string literals, a single quote is escaped by doubling it. The literal '<>''' has three quotes after the >: the first pair is one escaped quote character, and the third closes the string. The actual filter expression becomes <>' (not equal to a single quote) instead of <>'' (not equal to empty).
Two correct alternatives: escape the empty string properly with '<>''''', or avoid the escaping entirely with a placeholder ('<>%1', '').
Example
procedure SetCustomerFilter()
var
Customer: Record Customer;
begin
Customer.SetFilter("Customer Posting Group", '<>'''); // Invalid single-quote escaping in filter string [PC0019]
end;Escape the quotes correctly:
procedure SetCustomerFilter()
var
Customer: Record Customer;
begin
Customer.SetFilter("Customer Posting Group", '<>''''');
end;Or use a placeholder to avoid the escaping:
procedure SetCustomerFilter()
var
Customer: Record Customer;
begin
Customer.SetFilter("Customer Posting Group", '<>%1', '');
end;When the diagnostic is reported
- A
SetFiltercall passes the literal'<>'''as the filter expression. - A
CalcFormulaWHERE clause usesfilter('<>''').
Code fix
The code fix replaces '<>''' with the correctly escaped '<>'''''.
See also
- Record.SetFilter(Any, Text [, Any,…]) Method on Microsoft Learn
- Filtering records with SetRange, SetFilter, GetRangeMin, and GetRangeMax on Microsoft Learn