Closed epernst closed 8 months ago
Is the Rec.Code is a Code[20]
field?
In that case I believe when that fields contains a value of 20 characters, you'll get runtime error.
Otherwise can you provide a small code sample for a repo?
Yes, the Rec.Code is a code[20] and gives me the error. But it shouldn't, as an filter can be as long as you need it to be.
var Dimension: Record Dimension; RecCode: Code[20]; begin Dimension.SetFilter(Code, '%1', '@' + RecCode + '*'); end;
I'm probably doing something wrong here? Tested this with the example below, which throws me an runtime error.
pageextension 50100 "My Customer List" extends "Customer List"
{
trigger OnOpenPage()
var
Dimension: Record Dimension;
RecCode: Code[20];
begin
RecCode := 'ABCDEFGHIJKLMNOPQRST'; // Fill variable with 20 characters
Dimension.SetFilter(Code, '%1', '@' + RecCode + '*');
end;
}
I have copied this "pattern" from Microsoft, where it's used many places, so I'm a bit surprised that you're right!
In most cases of the Code field with masterdata, like Customers, Dimensions, etc, you're not easily going to hit this limit I believe.
Only in rare occasions where the setup of dimension value codes is like PROJ-WEU-2024-EUR-05
you're out of luck ;-)
We have a line that is giving an LC0051 error (Possible overflow assigning 'Text' to 'Code[20]'), where it shouldn't:
Dimension.SetFilter(Code, '%1', '@' + Rec.Code + '*');
The filter in SetFilter is a text without length and should not give this error. Had it been a SetRange, then it should give it. But not here.