Bug 634269: [Subcontracting] Fix second return from subcontractor failing after first posted#8222
Draft
ChethanT wants to merge 2 commits into
Draft
Bug 634269: [Subcontracting] Fix second return from subcontractor failing after first posted#8222ChethanT wants to merge 2 commits into
ChethanT wants to merge 2 commits into
Conversation
…d (bug 634269) The OnAfterDeleteEvent subscriber in SubcTransferLineExt fired UpdateLocationCodeInProdOrderCompAfterDeleteTransferLine unconditionally for ALL transfer lines, including return lines. When a return transfer order was posted and deleted, this incorrectly restored the component's location back to its original location and cleared Subc. Original Location Code. On the next return attempt, the system would use the corrupted component state, computing Transfer-from = Transfer-to (both SUBC), triggering the 'Transfer-from Code and Transfer-to Code cannot be the same' error. Fix: Add guard 'if Rec."Subc. Return Order" then exit' so the location restoration only runs for outbound transfer line deletions. Added test codeunit 149917 verifying second return succeeds after first return is posted. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Subcontracting/634269-ReturnTransferDeleteLocation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Cannot create a second return from subcontractor after the first return transfer order is posted and deleted. The error is:
Root Cause
The
OnAfterDeleteEventsubscriber inSubcTransferLineExt.Codeunit.alcallsUpdateLocationCodeInProdOrderCompAfterDeleteTransferLinefor ALL transfer line deletions, including return transfer lines. This procedure was designed only for outbound transfer cleanup (restoring the component location from SUBC back to MAIN when an outbound transfer is deleted/cancelled).When it fires for a return line deletion (after posting), it:
ProdOrderComponent."Location Code"to the Original Location Code"Subc. Original Location Code"to''On the next return attempt, the system sees
Orig Location Code = '', sets it to the current (corrupted) location, and computes Transfer-from = Transfer-to = SUBC → error.Fix
Added a guard in
OnAfterDeleteEvent:This ensures location restoration only runs for outbound transfer line deletions, not return lines.
Testing
New test codeunit 149917 that:
Fixes AB#634269