Bug 634953: Fix factbox drilldowns for finished production orders#8293
Bug 634953: Fix factbox drilldowns for finished production orders#8293ChethanT wants to merge 1 commit into
Conversation
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>
| ProdOrderComponent.SetRange("Routing Link Code", ProdOrderRoutingLine."Routing Link Code"); | ||
|
|
||
| ProdOrderComponent.SetRange(Status, ProdOrderComponent.Status::Released); | ||
| ProdOrderComponent.SetRange(Status, ProdOrderRoutingLine.Status); |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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
elsebranch that either opens a generic fallback page or raises an informative error.
| case ProductionOrder.Status of | |
| else | |
| Error('Unexpected production order status: %1', ProductionOrder.Status); |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
Summary
Changes
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