Bug 634267: [Subcontracting] Transfer Order Reopen not persisting from factbox drill-down (Bug 634267)#8170
Conversation
…g 634267) ShowTransferOrdersAndReturnOrder passed a MarkedOnly-filtered record to PageManagement.PageRun/PageRunList. When the Transfer Order page opened bound to this marked record, actions like Reopen that modify Rec directly wrote to the marked record set rather than the real database, so changes were silently lost when the page closed. The fix uses a separate TransferHeaderToOpen record variable: - Single record: Get() fetches the real DB record before PageRun. - Multiple records: SelectionFilterManagement builds a No. filter applied to a clean record before PageRunList. Added test FactboxDrilldownTransferOrderReopenPersists that releases a transfer order, opens it via ShowTransferOrdersAndReturnOrder, performs Reopen in the page handler, and asserts the status persists as Open. AB#634267 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| NoOfTransferHeaders > 1: | ||
| PageManagement.PageRunList(TransferHeader); | ||
| begin | ||
| TransferHeaderToOpen.SetFilter("No.", SelectionFilterMgt.GetSelectionFilterForTransferHeader(TransferHeader)); |
There was a problem hiding this comment.
Filter string may grow unbounded for large sets
GetSelectionFilterForTransferHeader iterates all marked TransferHeader records and encodes their "No." values into a pipe-separated filter string. If many transfer orders are marked (e.g., in a high-volume manufacturing environment), the resulting filter string could become very long, risk hitting AL text-length limits, and generate a complex SQL IN-style predicate that performs worse than the previous marked-record approach.
Recommendation:
- Consider guarding with a reasonable upper bound check before calling
GetSelectionFilterForTransferHeader, or fall back to the marked-record approach whenNoOfTransferHeadersexceeds a configurable threshold. Alternatively, document the expected max cardinality in a comment to make the assumption explicit.
| TransferHeaderToOpen.SetFilter("No.", SelectionFilterMgt.GetSelectionFilterForTransferHeader(TransferHeader)); | |
| NoOfTransferHeaders > 1: | |
| begin | |
| // Note: NoOfTransferHeaders is bounded by subcontracting purchase order scope; | |
| // a single PO is unlikely to have more than a few dozen linked transfer orders. | |
| TransferHeaderToOpen.SetFilter("No.", SelectionFilterMgt.GetSelectionFilterForTransferHeader(TransferHeader)); | |
| PageManagement.PageRunList(TransferHeaderToOpen); | |
| end; |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| using Microsoft.Purchases.History; | ||
| using Microsoft.Utilities; | ||
| using System.Reflection; | ||
| using System.Text; |
There was a problem hiding this comment.
Unused namespace import added
The using System.Text; statement was added in this PR but no type from the System.Text namespace (such as TextBuilder) is referenced anywhere in the file. The new SelectionFilterManagement codeunit does not belong to System.Text, so this import is dead code that can trigger AL compiler warnings about unused using directives.
Recommendation:
- Remove the
using System.Text;line. IfSelectionFilterManagementrequires an explicit namespace import to resolve without ambiguity, add its correct namespace instead (e.g.,using Microsoft.Foundation.Navigate;if needed).
| using System.Text; | |
| using System.Reflection; | |
| // remove: using System.Text; |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
Problem
When a Transfer Order is opened from the Subcontracting Details Factbox (e.g. clicking No. of Transfer Orders on a Purchase Order), actions like Reopen that modify
Recdirectly appear to succeed on screen but the change is silently lost when the page closes.Root Cause
ShowTransferOrdersAndReturnOrderinSubcPurchFactboxMgmtcollected Transfer Headers usingMark/MarkedOnlyand passed that marked record directly toPageManagement.PageRun/PageRunList. When the Transfer Order page opened bound to a marked record, operations that modifyRec(e.g. Reopen →Rec.Validate(Status, Open); Rec.Modify()) wrote to the marked record set in memory rather than the real database table. The change was discarded when the page closed.Actions like Post were unaffected because they call
TransferHeader.Get()internally on a separate variable, bypassingRec.Fix
Introduced a separate
TransferHeaderToOpenrecord variable that is populated from the real database:TransferHeaderToOpen.Get(TransferHeader.\"No.\")fetches the real DB record, thenPageManagement.PageRun(TransferHeaderToOpen).SelectionFilterManagement.GetSelectionFilterForTransferHeaderto build a "No." filter from the marked set, applies it toTransferHeaderToOpen, thenPageManagement.PageRunList(TransferHeaderToOpen).Test
Added
FactboxDrilldownTransferOrderReopenPersists:ShowTransferOrdersAndReturnOrder(the factbox drill-down path)AB#634267