Skip to content

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

Description

@Franco111000

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ApprovedThe issue is approvedSCMGitHub request for SCM area

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions