Skip to content

[Bug Fix] #638815: Subcontracting: actionable error for blank Subc. Location Code on WIP transfers#8754

Draft
ventselartur wants to merge 1 commit into
mainfrom
bugs/638815-NoValidationCheckOnBlankSubcLocationCode
Draft

[Bug Fix] #638815: Subcontracting: actionable error for blank Subc. Location Code on WIP transfers#8754
ventselartur wants to merge 1 commit into
mainfrom
bugs/638815-NoValidationCheckOnBlankSubcLocationCode

Conversation

@ventselartur

@ventselartur ventselartur commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Bug Reference

Azure DevOps work item #638815 — Subcontracting: No validation of blank Subc. Location Code for WIP transfers at any stage

Summary

When "Transfer WIP Item" is enabled on a subcontracting routing line but the subcontractor has no Subc. Location Code, the user could complete the entire flow (refresh prod. order, create subcontracting PO) and only hit a generic, unactionable error — "Nothing to create. No components or WIP to transfer for the specified subcontracting order." — when clicking Create Transf. Ord. to Subcontractor. This change raises a clear, actionable TestField error on the vendor's Subc. Location Code, mirroring how the components path already validates it.

Root Cause

In report 99001501 "Subc. Create Transf. Order", procedure CheckCreateWIPTransfer resolves the transfer-to location from the Purchase Header / Vendor Subc. Location Code. At that point it has already established that there is WIP to transfer (ExpectedQtyBase > 0). When the resolved location was blank, the procedure silently did exit(false), which propagated up through HandleWIPTransferForPurchLineCheckTransferCreated and surfaced only the generic NothingToCreateErr. The components path, by contrast, calls Vendor.TestField("Subc. Location Code") in GetTransferToLocationCode, giving an early actionable error.

Changes Made

  • src/Apps/W1/Subcontracting/App/src/Transfer/SubcCreateTransfOrder.Report.al: in CheckCreateWIPTransfer, replace the silent exit(false) for a blank transfer-to location with VendorFromPurchOrder.TestField("Subc. Location Code"), surfacing an actionable misconfiguration error consistent with the components path.
  • src/Apps/W1/Subcontracting/Test/Tests/SubcWIPTransCreateTest.Codeunit.al: add regression test WIPTransferCreationFailsWithTestFieldErrorWhenSubcLocationBlank (codeunit 149911) that clears both the Vendor and Purchase Header Subc. Location Code on a WIP-transfer-enabled flow and asserts the TestField error instead of the generic message.

Implementation Process

  • Fix iterations: 1 (plus a test-assertion caption correction — the field Caption is "Subcontracting Location Code")
  • Compilation: ✅ All projects compile successfully (al_build scope=all, green)
  • Tests: ✅ All tests passing

Test Evidence

Pre-Fix Test Results (Baseline)

❌ WIPTransferCreationFailsWithTestFieldErrorWhenSubcLocationBlank: FAILED (as expected on unfixed code)
   Actual: Error "Nothing to create. No components or WIP to transfer for the specified subcontracting order." (code TestWrapped:Dialog)
   Expected (after fix): TestField error on Vendor "Subc. Location Code"

Post-Fix Test Results (Final)

✅ WIPTransferCreationFailsWithTestFieldErrorWhenSubcLocationBlank: PASSED (new regression test)
✅ 18 existing WIP-transfer-create tests: PASSED

Total Tests Run: 19 (codeunit 149911)
All Tests Passing: ✅ Yes

Test Coverage

  • Existing tests pass (18/18)
  • New regression test added for the bug scenario
  • Regression test for work item #638815
  • Edge case covered: blank Subc. Location Code on the WIP path with WIP available to transfer

Review Notes

The fix is a single-line change in CheckCreateWIPTransfer. Because TestField always errors on a blank value, control never falls through, so no explicit exit is required after it. The behavior now matches the existing components-path validation in GetTransferToLocationCode.

🤖 Generated by the bc-fix-bug skill

@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Jun 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Could not find a linked ADO work item. Please link one by using the pattern 'AB#' followed by the relevant work item number. You may use the 'Fixes' keyword to automatically resolve the work item when the pull request is merged. E.g. 'Fixes AB#1234'

@ventselartur ventselartur added the Subcontracting Subcontracting related activities label Jun 24, 2026
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 Subcontracting Subcontracting related activities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant