Skip to content

Update Subcontracting Sync tests to use Component Supply Method API#8505

Merged
mazhelez merged 2 commits into
mainfrom
copilot/fix-subcontracting-test-compilation
Jun 5, 2026
Merged

Update Subcontracting Sync tests to use Component Supply Method API#8505
mazhelez merged 2 commits into
mainfrom
copilot/fix-subcontracting-test-compilation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 5, 2026

Subcontracting test compilation broke because Subcontracting Type references remained after the model/API rename to Component Supply Method. This updates SubcSubcontractingSyncTest to align with current enum values, record fields, and library procedure names.

  • API call alignment in Sync tests

    • Replaced both calls to removed UpdateProdBomWithSubcontractingType(...) with UpdateProdBomWithComponentSupplyMethod(...).
    • Updated enum argument from "Subcontracting Type"::Transfer to "Component Supply Method"::"Transfer to Vendor".
  • Prod. Order Component field rename alignment

    • In SetAllProdOrderTransferComponentLocations, replaced filter on removed "Subcontracting Type" with "Component Supply Method" and corresponding enum value.
  • Scope

    • Changes are limited to:
      src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingSyncTest.Codeunit.al
SubcontractingMgmtLibrary.UpdateProdBomWithComponentSupplyMethod(
    Item,
    "Component Supply Method"::"Transfer to Vendor");
Original prompt

Problem

The CI/CD build fails during compilation of the Subcontracting Test project (src/Apps/W1/Subcontracting/Test) with these errors:

AL0132 'Codeunit Microsoft.Manufacturing.Subcontracting.Test."Subc. Management Library"' does not contain a definition for 'UpdateProdBomWithSubcontractingType'
AL0118 The name '"Subcontracting Type"' does not exist in the current context.
AL0132 'Record "Prod. Order Component"' does not contain a definition for 'Subcontracting Type'

Failing job: https://github.com/microsoft/BCApps/actions/runs/26949370499/job/79513223637

Root Cause

The "Subcontracting Type" enum has been removed/renamed to "Component Supply Method" (defined in src/Apps/W1/Subcontracting/App/src/Process/Enumerations/ComponentSupplyMethod.Enum.al), and the old enum value "Subcontracting Type"::Transfer now corresponds to "Component Supply Method"::"Transfer to Vendor".

The Subc. Management Library codeunit (src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcManagementLibrary.Codeunit.al) already has the correct replacement procedure UpdateProdBomWithComponentSupplyMethod (line 77), but the test file still calls the old UpdateProdBomWithSubcontractingType.

Required Changes

All changes are in file: src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingSyncTest.Codeunit.al

1. Line 143 — Replace call to removed procedure

Before:

SubcontractingMgmtLibrary.UpdateProdBomWithSubcontractingType(Item, "Subcontracting Type"::Transfer);

After:

SubcontractingMgmtLibrary.UpdateProdBomWithComponentSupplyMethod(Item, "Component Supply Method"::"Transfer to Vendor");

2. Line 213 — Same replacement (second test procedure)

Before:

SubcontractingMgmtLibrary.UpdateProdBomWithSubcontractingType(Item, "Subcontracting Type"::Transfer);

After:

SubcontractingMgmtLibrary.UpdateProdBomWithComponentSupplyMethod(Item, "Component Supply Method"::"Transfer to Vendor");

3. Line 488 — Replace removed field on Prod. Order Component record

In the SetAllProdOrderTransferComponentLocations local procedure:

Before:

ProdOrderComp.SetRange("Subcontracting Type", ProdOrderComp."Subcontracting Type"::Transfer);

After:

ProdOrderComp.SetRange("Component Supply Method", ProdOrderComp."Component Supply Method"::"Transfer to Vendor");

Verification

  • The "Component Supply Method" enum is already available via the using Microsoft.Manufacturing.Subcontracting; import at line 22 of the test file.
  • The UpdateProdBomWithComponentSupplyMethod procedure already exists in the Subc. Management Library codeunit (line 77 of SubcManagementLibrary.Codeunit.al) and takes the same pattern of parameters (Item record + enum value).
  • The "Prod. Order Component" record already has a "Component Supply Method" field (used throughout the app code in pages, reports, and codeunits).

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: ## Compilation Failure in "Subcontracting Test" Project

The build fails during compilation of the Subcontracting Test project with these errors:

Error Description
AL0132 'Codeunit "Subc. Management Library"' does not contain a definition for 'UpdateProdBomWithSubcontractingType'
AL0118 The name '"Subcontracting Type"' does not exist in the current context.
AL0132 'Record "Prod. Order Component"' does not contain a definition for 'Subcontracting Type'

Root Cause

The Subcontracting Test project references:

  1. A procedure UpdateProdBomWithSubcontractingType in the Subc. Management Library codeunit that no longer exists (likely renamed or removed).
  2. A field "Subcontracting Type" on the "Prod. Order Component" record that has been removed or renamed in the main Subcontracting app.

This indicates the main Subcontracting app had a breaking change (field/procedure rename or removal) but the test project was not updated to match.

Solution

You need to update the test files to align with the current Subcontracting app API:

  1. In Subc. Management Library (test helper codeunit): Either re-add the UpdateProdBomWithSubcontractingType procedure or, if the underlying logic was renamed, add the new equivalent procedure and update all callers.

  2. In the test files referencing "Subcontracting Type": Replace the field reference with whatever the field was renamed to in the "Prod. Order Component" table.

For example, if the field was renamed to something like "Subcontracting Work Type", the fix would look like:

// Before (broken):
ProdOrderComponent."Subcontract...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>


[AB#637825](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/637825)

Copilot AI changed the title [WIP] Fix Subcontracting Test compilation errors Update Subcontracting Sync tests to use Component Supply Method API Jun 5, 2026
Copilot AI requested a review from mazhelez June 5, 2026 07:46
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Jun 5, 2026
@mazhelez mazhelez marked this pull request as ready for review June 5, 2026 07:48
@mazhelez mazhelez requested a review from a team as a code owner June 5, 2026 07:48
@github-actions github-actions Bot added this to the Version 29.0 milestone Jun 5, 2026
@mazhelez mazhelez merged commit b08217c into main Jun 5, 2026
61 of 69 checks passed
@mazhelez mazhelez deleted the copilot/fix-subcontracting-test-compilation branch June 5, 2026 09:25
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.

3 participants