[Master]-Opening price list from Customer Card is extremely slow on large datasets (~220s) due to AddAllSourceType call#9269
Conversation
Copilot PR ReviewIteration 4 · Outcome: completed Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630 Findings by domainFindings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).
Totals: 0 knowledge-backed · 1 agent findings. Orchestrator pre-filter (13 file(s) excluded)
Findings produced by the Copilot CLI agent against BCQuality at |
Agentic PR Review - Round 1Recommendation: Request ChangesWhat this PR doesThis PR removes The performance goal is valid, but this implementation still does not preserve the exact set of source tuples. It ORs each source field independently, so a line can match a combination that was never present in SuggestionsS1 - Preserve exact source tuples S2 - Keep event-added filters S3 - Strengthen regression and performance coverage Risk assessment and necessityRisk: This code filters price list lines for Customer, Vendor, Job, Contact, and related review flows. If the filter admits mixed source combinations, the page can show price list lines for sources the caller did not ask for. The event contract is also risky because subscriber-added filters no longer affect the final result. Necessity: The work item is valid and important: opening Sales Prices from Customer Card can take about 220 seconds with 61k+ price lines. A fix is needed, but PR 9269 should not merge as-is. It is an unsafe alternative/replacement for the same AB#641061 work as closed PR 9219 and open PR 9265.
|
| if SourceTypeFilter = '' then | ||
| exit; | ||
|
|
||
| PriceListLine.SetFilter("Source Type", SourceTypeFilter); |
There was a problem hiding this comment.
you might hit max filter length (2100)
There was a problem hiding this comment.
Pull request overview
Improves performance when opening Price List Line Review from the Customer Card by avoiding expensive record marking/materialization when it isn’t required, while adding a UI test to validate the expected “All Customers” lines appear.
Changes:
- Update
Price List Managementto only useMarkedOnly(true)when multiple source result sets require marking. - Switch source filtering existence checks from
FindSet()toIsEmpty()to avoid unnecessary result-set materialization. - Add a UI test covering opening Sales Prices from Customer Card and verifying all “All Customers” lines are shown.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Layers/W1/Tests/ERM/PriceListsUI.Codeunit.al | Adds a UI regression test validating “All Customers” price lines are shown when opening from Customer Card. |
| src/Layers/W1/BaseApp/Pricing/PriceList/PriceListManagement.Codeunit.al | Avoids MarkedOnly(true)/marking when filtering can be done via a single source filter set, improving performance on large datasets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agentic PR Review - Round 2Recommendation: Request ChangesWhat this PR doesSince round 1, the PR changed This addresses the independent OR-filter bug and mostly addresses subscriber-added filters, because rows are checked after Status of previous suggestions
New observations (commits since round 1)S4 - Avoid marking mixed source result sets Risk assessment and necessityRisk: The changed code is in shared Price List Line Review filtering, so it affects Customer, Vendor, Job, Contact, and Campaign price/discount views. No public event signature changed, but the performance risk remains for mixed-source data because the code still uses Necessity: The linked Bug is clear and important: opening the page can take about 220 seconds on large data. The fix is needed, but it must cover or measure the mixed-source case that this page can produce.
|
| PriceListLine.SetRange("Source Type", PriceSource."Source Type"); | ||
| PriceListLine.SetRange("Parent Source No.", PriceSource."Parent Source No."); | ||
| PriceListLine.SetRange("Source No.", PriceSource."Source No."); | ||
| OnBuildSourceFiltersOnBeforeFindLines(PriceListLine, PriceSource); |
There was a problem hiding this comment.
CheckIfPriceListLineMarkingIsNeededForSources (new in this PR) re-raises the published IntegrationEvent OnBuildSourceFiltersOnBeforeFindLines while pre-checking how many source groups have matching Price List Lines, and BuildSourceFilters raises the same event again for the real pass.
Any external subscriber to this event will now fire twice per source whenever SearchIfPriceExists is false (the normal 'set filters for display' path), instead of once as before this change. Note this diverges from the file's own established twin pattern: the pre-existing asset equivalent (CheckIfPriceListLineMarkingIsNeeded, added earlier for BuildAssetFilters) deliberately raises a separate, dedicated event OnCheckIfPriceListLineMarkingIsNeededOnBeforeFindLines for its check pass so OnBuildAssetFiltersOnBeforeFindLines still fires exactly once per source. If a subscriber to OnBuildSourceFiltersOnBeforeFindLines does anything beyond idempotent filter narrowing (e.g. counts invocations, appends to an accumulator, or performs a side-effecting call), the doubled firing will silently change its behavior for any AppSource extension using this event -- an impact that would normally be major/blocker for a published extensibility contract, but is capped to minor here because it is not backed by a BCQuality knowledge article; consider promoting this to a knowledge-backed rule about not re-using a 'build' IntegrationEvent from a separate 'check-only' pass.
Recommendation:
- introduce a dedicated event (e.g. OnCheckSourceFiltersMarkingIsNeededOnBeforeFindLines) for the check pass, mirroring the asset implementation, so OnBuildSourceFiltersOnBeforeFindLines keeps firing once per source as it did before this change.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
Agentic PR Review - Round 3Recommendation: Request ChangesWhat this PR doesSince round 2, the PR adds The linked bug is specifically about large Customer Card datasets. That page can include customer-specific, price group, discount group, and All Customers sources. If more than one of those sources has records, the current code still materializes and marks the large result set, so the performance fix is still not proven for the real scenario. This is also still a duplicate-PR situation for AB#641061: PR 9219 is closed, but PR 9265 and PR 9269 are both open. One of PR 9265/9269 should be closed. Status of previous suggestions
New observations (commits since round 2)S3 - Strengthen regression and performance coverage S4 - Avoid marking mixed source result sets Risk assessment and necessityRisk: This code is shared by Customer, Vendor, Job, Contact, Campaign, and related price/discount review flows. Loading fewer fields may help memory and SQL payload, but it does not prove that the 61k+ mixed-source scenario loads in the expected time. Necessity: AB#641061 is clear and important because opening Sales Prices from Customer Card can take about 220 seconds. A fix is needed, but it must cover the mixed-source case or include a performance guard. Also, PR 9265 is still open for the same work item, so one duplicate PR should be closed before merge.
|
Agentic PR Review - Round 4Recommendation: Request ChangesWhat this PR doesSince round 3, Removing marking for the multi-source case helps performance, but it brings back the tuple-mixing problem from round 1. The three OR filters are independent, so the final query is Status of previous suggestions
New observations (commits since round 3)None beyond the reopened items above. The rewrite fixed S4 but reintroduced S1 and S2. Risk assessment and necessityRisk: The mixed-source path can now return price list lines for sources the caller did not ask for. This code is shared by Customer, Vendor, Job, Contact, and Campaign price/discount views. Dropping event-added filters can also show more lines than a subscriber intended. Both are correctness risks on a widely used page. Necessity: AB#641061 is clear and important, because opening Sales Prices from Customer Card can take about 220 seconds. A fast fix is needed, but it must keep the exact source tuples and the subscriber-added filters. The duplicate PR 9265 is now closed, so that earlier concern is resolved.
|
AB#641061