Skip to content

Bug 634953: Fix factbox drilldowns for finished production orders#8293

Open
ChethanT wants to merge 1 commit into
mainfrom
bugs/634953
Open

Bug 634953: Fix factbox drilldowns for finished production orders#8293
ChethanT wants to merge 1 commit into
mainfrom
bugs/634953

Conversation

@ChethanT
Copy link
Copy Markdown
Contributor

@ChethanT ChethanT commented May 25, 2026

Summary

  • Bug: Subcontracting factbox drilldowns in Purchase Order and Transfer Order break after the linked production order is finished.
  • Root cause: \Subc. ProdO. Factbox Mgmt.\ (CU 99001559) hardcodes \SetRange(Status, ::Released)\ in all 5 procedures, so no data is returned once status moves to Finished.
  • Fix: Replace \SetRange(Status, ::Released)\ with \SetFilter(Status, '>=%1', ::Released)\ across all filter procedures so that both Released and Finished production orders are found. \ShowProductionOrder\ now opens the correct page (\Released Production Order\ or \Finished Production Order) based on the resolved status.

Changes

  • \SubcProdOFactboxMgmt.Codeunit.al\ — Fixed all 5 affected procedures
  • \SubcSubcontractingTest.Codeunit.al\ — Added \ProdOFactboxMgmtShowsDataAfterProdOrderFinished\ test ([SCENARIO 634953])

Test

Added \ProdOFactboxMgmtShowsDataAfterProdOrderFinished\ in codeunit 139989 — verifies that \CalcNoOfProductionOrderRoutings\ and \CalcNoOfProductionOrderComponents\ return positive counts after the production order is finished.

Fixes AB#634953

🤖 Generated with GitHub Copilot

Subc. ProdO. Factbox Mgmt. (CU 99001559) hardcoded Status::Released in all
procedures that query production order data. After finishing a production order,
factbox fields showed zero counts and drilldowns failed with errors.

Fix: Replace SetRange(Status, ::Released) with SetFilter(Status, '>=%1', ::Released)
so queries match both Released and Finished orders. ShowProductionOrder now opens
the correct page based on the resolved status (Released or Finished Production Order).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ChethanT ChethanT requested a review from a team as a code owner May 25, 2026 21:31
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label May 25, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone May 25, 2026
ProdOrderComponent.SetRange("Routing Link Code", ProdOrderRoutingLine."Routing Link Code");

ProdOrderComponent.SetRange(Status, ProdOrderComponent.Status::Released);
ProdOrderComponent.SetRange(Status, ProdOrderRoutingLine.Status);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟠\ High\ Severity\ —\ Performance} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

Stale routing-line status used after failed FindFirst

When ProdOrderRoutingLine.FindFirst() returns false the record variable retains its default Status value (Simulated = 0). The immediately following ProdOrderComponent.SetRange(Status, ProdOrderRoutingLine.Status) then filters components by Simulated status, finding nothing and silently returning 0 components instead of the expected count.

Recommendation:

  • Only set the component status filter when a routing line was actually found, or fall back to the production order's status otherwise. Alternatively, store the production order status and use it unconditionally for the component filter.
Suggested change
ProdOrderComponent.SetRange(Status, ProdOrderRoutingLine.Status);
if ProdOrderRoutingLine.FindFirst() then begin
ProdOrderComponent.SetRange("Routing Link Code", ProdOrderRoutingLine."Routing Link Code");
ProdOrderComponent.SetRange(Status, ProdOrderRoutingLine.Status);
end else
ProdOrderComponent.SetRange(Status, ProdOrderComponent.Status::Released);

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why

ReleasedProductionOrder.Run();
if not ProductionOrder.FindFirst() then
exit;
case ProductionOrder.Status of
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Style} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

Case statement silently ignores unexpected status

The case ProductionOrder.Status of block handles only Released and Finished. Although the preceding SetFilter('>=%1', Released) makes other statuses theoretically unreachable today, any future enum addition or unexpected data would cause ShowProductionOrder to silently exit without opening any page, giving the user no feedback.

Recommendation:

  • Add an else branch that either opens a generic fallback page or raises an informative error.
Suggested change
case ProductionOrder.Status of
else
Error('Unexpected production order status: %1', ProductionOrder.Status);

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant