[Bug]: Prices Overview data caption shows the first record's name instead of the filtered record
Nobody has claimed this yet.
- Dominant language
- AL
- Stars
- 683
- Forks
- 459
- Avg merge
- 3d 26m
- Merged PRs (30d)
- 633
Description
Describe the issue
Page 7024 "Prices Overview" builds its data caption in GetFilterDescription() by assigning the source number to a record field and then calling FindFirst() without any filter:
PriceSource."Source Type"::Customer:
begin
SalesSrcTableName := ObjTranslation.TranslateObject(ObjTranslation."Object Type"::Table, 18);
Cust."No." := CopyStr(SourceNoFilter, 1, MaxStrLen(Cust."No."));
if Cust.FindFirst() then
Description := Cust.Name;
end;
Assigning to Cust."No." does not filter the record, so FindFirst() returns the first customer in the table and the caption shows an unrelated customer's name next to the correct number. The Customer Price Group and Campaign branches have the same defect.
Verified still present in current main: src/Layers/W1/BaseApp/Pricing/PriceList/PricesOverview.Page.al, GetFilterDescription(). The APAC layer copy of the page (src/Layers/APAC/BaseApp/Pricing/PriceList/PricesOverview.Page.al) contains the same pattern.
The fix is to replace the field assignments with SetFilter/SetRange on the key field before FindFirst() in all three branches.
Expected behavior
The page caption shows the name of the record actually selected in the Source No. filter.
Steps to reproduce
- Create a page action in AL that runs Prices Overview modally.
- Run the action in Business Central.
- Choose Source Type "Customer" and as Source No. any customer except the first one in the table.
- The caption shows the chosen customer's number but the first customer's name.
Additional context
This is a copy of microsoft/BusinessCentralApps#1371 (labeled Approved/SCM in the contribution pilot). It was being fixed in microsoft/BusinessCentralApps#1911, which was reviewed with regression tests added, but was closed unmerged with a note about test failures when the repository was retired. The likely cause of those failures has been identified (the tests opened the page in view mode on an empty Price List Line table, where the platform suppresses the DataCaptionExpression, see microsoft/AL#6388) and will be corrected in the re-submitted fix.
I will provide a fix for a bug
- I will provide a fix for a bug
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/Layers/W1/BaseApp/Pricing/PriceList/PricesOverview.Page.al at GetFilterDescription(), then compare the APAC copy at src/Layers/APAC/BaseApp/Pricing/PriceList/PricesOverview.Page.al. Inspect the Customer, Customer Price Group, and Campaign branches and their record lookups. Done means the caption uses the selected source record's name in each branch and the regression tests pass.
Written by the indexing model from the issue text.
Assessment
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100