AL icon indicating copy to clipboard operation
AL copied to clipboard

Runtime bug in query that should be checked by compilator/codecops

Open fridrichovsky opened this issue 8 months ago • 0 comments

When query field is used for in MaxStrLen function it raise runtime error that is visible in Application Event Log. BC Webclient raise only something wrong.

Error say that field can't be used before Read.

Code example:

MyQuery.SetRange(ResourceNo, "Resource No.");
MyQuery.SetFilter(Department, '<>%1', CopyStr(HelpDepartments, 1, MaxStrLen(MyQuery.Department)));
MyQuery.Open();
while MyQuery.Read() do begin

I understand that read is necessary when we work with data, but for determining text size is new for me.

Please add to compilator check that field is not used before read. It helps with runtime error that developer do not see.

Problem was that function and query was used long time, but warning said that there is overflow in text. So when we solved warning we created new error in runtime.

Thank you Internal work item: AB#580025

fridrichovsky avatar May 15 '25 13:05 fridrichovsky