Skip to content

Filter the source record before FindFirst in Prices Overview caption#9181

Open
Franco111000 wants to merge 1 commit into
microsoft:mainfrom
Franco111000:fix-9101-prices-overview-setfilter
Open

Filter the source record before FindFirst in Prices Overview caption#9181
Franco111000 wants to merge 1 commit into
microsoft:mainfrom
Franco111000:fix-9101-prices-overview-setfilter

Conversation

@Franco111000

@Franco111000 Franco111000 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What & why

Page 7024 "Prices Overview" builds its data caption in GetFilterDescription() by assigning the source number to a record field and then calling FindFirst() without a filter. Assignment is not filtering, so FindFirst() returns the first record of the table and the caption shows an unrelated record's name next to the correct number. The Customer, Customer Price Group, and Campaign branches all have the defect.

This change replaces the assignments with SetFilter on the key field in all three branches, so the caption looks up the record actually selected in the Assign-to Filter. The APAC layer carries a full copy of the page with identical code and receives the same three-line change, following the practice of propagating W1 fixes to layer copies.

Three regression tests cover the three branches: each creates a record whose name is not derived from its number, opens Prices Overview, sets the type and number filters, and asserts the caption contains the record's name. The tests open the page in edit mode deliberately: the platform suppresses DataCaptionExpression on a page opened in view mode with no records (microsoft/AL#6388), and Prices Overview starts on an empty Price List Line table in the test setup. This is also the most plausible cause of the internal test failures reported on the pilot PR, which used view mode.

This is a re-submission of microsoft/BusinessCentralApps#1911 (pilot repository, retired). The fix was reviewed there and closed unmerged with a note about test failures when the repository was retired; the view-mode issue described above is corrected in this version.

Linked work

Fixes #9101

Original pilot review: microsoft/BusinessCentralApps#1911 (fixing microsoft/BusinessCentralApps#1371).

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

What I tested and the outcome

  • Verified against current main that the assignment plus unfiltered FindFirst() pattern is still present in GetFilterDescription(), byte-identical in the W1 page and the APAC layer copy, and that no other layer carries a copy.
  • The three new tests (T217, T218, T219 in PriceListsUI.Codeunit.al) each verify that the caption shows the name of the selected record and not the first record in the table. They use OpenEdit() for the reason described above; the page has no page-level Editable = false, so edit mode is valid.
  • Test numbering continues the codeunit's existing T-series (T216 was the highest in use).
  • I did not build the Base Application locally; the change is three SetFilter replacements per page copy plus tests and relies on CI for compilation and the test run.

Risk & compatibility

  • Caption-only change: no persisted data, posting, or price calculation is affected.
  • SourceNoFilter is a filter value entered in a filter field, so passing it to SetFilter is the intended semantics; when the filter matches several records the caption shows the first match, which is strictly better than showing an unrelated record.
  • No schema, permission, or signature changes.

GetFilterDescription on page 7024 Prices Overview assigned the source
number to a record field and called FindFirst without a filter, so the
caption showed the name of the first record in the table instead of the
selected one. The Customer, Customer Price Group, and Campaign branches
now apply SetFilter before FindFirst. The APAC layer copy of the page
carries the same code and receives the same change.

The regression tests open the page in edit mode because the platform
suppresses DataCaptionExpression on a view-mode page without records.

Fixes microsoft#9101. Re-submission of microsoft/BusinessCentralApps#1911.
@Franco111000 Franco111000 requested a review from a team July 7, 2026 12:09
@github-actions github-actions Bot added the From Fork Pull request is coming from a fork label Jul 7, 2026
@github-actions github-actions Bot added the needs-approval Workflow runs require maintainer approval to start label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

From Fork Pull request is coming from a fork needs-approval Workflow runs require maintainer approval to start

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant