microsoft / microsoft/BCApps

[Bug]: Prices Overview data caption shows the first record's name instead of the filtered record

Open
#9,101 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Approved Team: SCM
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
  1. Create a page action in AL that runs Prices Overview modally.
  2. Run the action in Business Central.
  3. Choose Source Type "Customer" and as Source No. any customer except the first one in the table.
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.