Skip to content

[Subcontracting] Subcontractor Price with Blank Unit of Measure Not Shown in Purchase Order FactBox#8695

Open
stevengrossGOB wants to merge 1 commit into
microsoft:mainfrom
GOB-Software-Systeme-DevOps:w/grosss/scenario11_factbox
Open

[Subcontracting] Subcontractor Price with Blank Unit of Measure Not Shown in Purchase Order FactBox#8695
stevengrossGOB wants to merge 1 commit into
microsoft:mainfrom
GOB-Software-Systeme-DevOps:w/grosss/scenario11_factbox

Conversation

@stevengrossGOB

@stevengrossGOB stevengrossGOB commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Bug: Subcontractor Price with Blank Unit of Measure Not Shown in Purchase Order FactBox

Affected Objects

Type Name ID
Table Subcontractor Price 99001500
Codeunit Subc. Purch. Factbox Mgmt. 99001511
Page Subc. Purchase Line Factbox 99001518

Reproduction Steps

Setup

  • A Subcontractor Price entry exists for a Vendor / Item / Work Center combination with Unit of Measure Code left blank (meaning the price applies to any unit).

Given

  • A Subcontracting Purchase Order line for the same Vendor, Item, and Work Center.
  • The Purchase Line has a specific Unit of Measure Code (e.g., PCS).

When

  • The user opens the Purchase Order and views the Subcontracting Details FactBox.

Then

  • The Subcontractor Prices field in the FactBox displays 0 instead of 1.

False Behavior

The FactBox shows 0 Subcontractor Prices even though a matching price exists with a blank Unit of Measure Code. The price is not found because FilterSubContractorPriceForPurchLine uses SetRange("Unit of Measure Code", PurchaseLine."Unit of Measure Code"), which requires an exact match. A blank-UoM price is only found when the purchase line's UoM is also blank.

Expected Behavior

A Subcontractor Price with a blank Unit of Measure Code should be treated as a "catch-all" using the base unit of measure. The FactBox should count (and drilldown should display) such entries regardless of the Unit of Measure Code on the purchase line.

Root Cause

File: src/Process/Codeunits/SubcPurchFactboxMgmt.Codeunit.al
Procedure: FilterSubContractorPriceForPurchLine (local)

The offending line:

SubcontractorPrice.SetRange("Unit of Measure Code", PurchaseLine."Unit of Measure Code");

SetRange performs an exact equality filter. When the purchase line has "Unit of Measure Code" = 'PCS' and the Subcontractor Price has "Unit of Measure Code" = '', no record is returned.

Fix Description

Replace the SetRange on "Unit of Measure Code" with a SetFilter that also accepts blank entries:

SubcontractorPrice.SetFilter("Unit of Measure Code", '%1|%2', PurchaseLine."Unit of Measure Code", '');

This ensures prices entered without a Unit of Measure (applicable to any unit) are included in the FactBox count and drilldown, while prices entered for a specific unit are still matched correctly when the purchase line uses that same unit.

When the purchase line itself has a blank UoM the filter becomes '' | '' (blank or blank), which is equivalent to the original SetRange — no regression for that case.

Related Work Item

To be added.

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

@stevengrossGOB stevengrossGOB requested a review from a team June 19, 2026 12:13
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork labels Jun 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Could not find linked issues in the pull request description. Please make sure the pull request description contains a line that contains 'Fixes #' followed by the issue number being fixed. Use that pattern for every issue you want to link.

@github-actions github-actions Bot added the needs-approval Workflow runs require maintainer approval to start label Jun 19, 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 From Fork Pull request is coming from a fork needs-approval Workflow runs require maintainer approval to start

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant