[Bug]: [Quality Management] Warehouse Receipt Trigger "When Warehouse Receipt is created" never fires for receipt lines from inbound transfers or sales returns
Describe the issue
Inspection Generation Rules offer "Warehouse Receipt Trigger" = "When Warehouse Receipt is created" (Qlty. Whse. Receipt Trigger::OnWarehouseReceiptCreate). Neither the field tooltip (QltyInspectionGenRule.Table.al, field 22) nor the enum caption limits it to a source document type, and the rule page lets you configure it for any applicable rule. In practice it only works for warehouse receipt lines created from purchase orders.
The only subscriber for this trigger is HandleOnAfterCreateRcptLineFromPurchLine in codeunit 20411 "Qlty. Receiving Integration" (src/Apps/W1/Quality Management/app/src/Integration/Receiving/QltyReceivingIntegration.Codeunit.al:116), which subscribes to codeunit "Purchases Warehouse Mgt.", event OnAfterCreateRcptLineFromPurchLine, and calls the local helper AttemptCreateInspectionWithReceiptLine (:280).
Warehouse receipts are also created from inbound transfer orders and from sales return orders, and the Base Application publishes structurally identical events at those creation points:
- codeunit 5993 "Transfer Warehouse Mgt.",
OnAfterCreateRcptLineFromTransLine(var WarehouseReceiptLine; WarehouseReceiptHeader; TransferLine), raised at the end ofTransLine2ReceiptLine(src/Layers/W1/BaseApp/Inventory/Transfer/TransferWarehouseMgt.Codeunit.al:238) - codeunit "Sales Warehouse Mgt.",
OnAfterCreateRcptLineFromSalesLine(var WarehouseReceiptLine; WarehouseReceiptHeader; SalesLine)(src/Layers/W1/BaseApp/Sales/Document/SalesWarehouseMgt.Codeunit.al:419)
Quality Management references neither event anywhere in its source.
The omission looks unintentional rather than by design, because the surrounding code is already prepared for these sources:
- The helper
AttemptCreateInspectionWithReceiptLineis source agnostic. Its integration eventOnBeforeAttemptCreateInspectionWithReceiptLinedocuments the optional source line as "purchase line, sales line, transfer line" (QltyReceivingIntegration.Codeunit.al:509). "Qlty. Warehouse Integration".CollectSourceItemTrackingalready has aDatabase::"Transfer Line"branch callingTransferLineReserve.FindInboundReservEntry(src/Apps/W1/Quality Management/app/src/Integration/Warehouse/QltyWarehouseIntegration.Codeunit.al:137), next to the Purchase Line and Sales Line branches.- The shipped source configurations in
QltyAutoConfigure.Codeunit.alinclude Warehouse Receipt Line to Sales Line, gatedWHERE(Source Type=CONST(37))(:1073), alongside the purchase one gatedCONST(39)(:1106). So the sales return side of this trigger was clearly anticipated, yet no subscriber exists for it either.
One additional piece is missing for transfers specifically: there is no shipped source configuration linking Warehouse Receipt Line to Transfer Line (table 5741). QltyAutoConfigure does ship an Inbound Transfer Line to Inspection configuration (:1813) used by the posting-time path, but the warehouse receipt entry point cannot traverse to a transfer line. Even with a subscriber added, a rule targeting the warehouse receipt line would produce an inspection with no source fields for transfer-sourced lines. Subscriber and source configuration are needed together.
Net effect: goods arriving by purchase order can be inspected on the dock at receipt creation; goods arriving by inbound transfer can only be inspected after the transfer receipt is posted (Transfer Order Trigger = "OnTransferOrderPostReceive"), when they are already booked into inventory. Quarantine-before-put-away flows are not possible for transfers.
Expected behavior
A generation rule with Warehouse Receipt Trigger = "When Warehouse Receipt is created" creates inspections for warehouse receipt lines regardless of the source document type (purchase order, inbound transfer order, sales return order). If a source type is intentionally out of scope, the tooltip and documentation should say so.
Steps to reproduce
- Install Quality Management, complete setup, and create an Inspection Generation Rule for source table "Warehouse Receipt Line" with a valid template and Warehouse Receipt Trigger = "When Warehouse Receipt is created", Activation Trigger = "Manual or Automatic".
- Create and release a purchase order for an item at a location with warehouse receipt handling, then Create Warehouse Receipt. An inspection is created for the receipt line. This is the working reference case.
- Create and release a transfer order inbound to the same location for the same item, then Create Warehouse Receipt for it. No inspection is created and nothing indicates why.
- Same result for a warehouse receipt created from a sales return order.
Additional context
Suggested fix, mirroring the existing purchase path.
1. New subscriber in codeunit 20411 "Qlty. Receiving Integration" (both Microsoft.Inventory.Transfer and Microsoft.Sales.Document are already in the file's using list, so no new using directives are needed):
[InherentPermissions(PermissionObjectType::TableData, Database::"Qlty. Management Setup", 'R', InherentPermissionsScope::Permissions)]
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Transfer Warehouse Mgt.", 'OnAfterCreateRcptLineFromTransLine', '', true, true)]
local procedure HandleOnAfterCreateRcptLineFromTransLine(var WarehouseReceiptLine: Record "Warehouse Receipt Line"; WarehouseReceiptHeader: Record "Warehouse Receipt Header"; TransferLine: Record "Transfer Line")
var
OptionalSource: Variant;
begin
if DetectIsPreviewPosting() then
exit;
if not QltyManagementSetup.GetSetupRecord() then
exit;
if not HasWarehouseReceiptCreateGenRule(ApplicableReceivingQltyInspectionGenRule) then
exit;
OptionalSource := TransferLine;
QltyBatchNotifHelper.BeginBatch();
AttemptCreateInspectionWithReceiptLine(WarehouseReceiptLine, WarehouseReceiptHeader, OptionalSource);
QltyBatchNotifHelper.EndBatch();
end;
The sales return equivalent is identical in shape, subscribing to "Sales Warehouse Mgt." OnAfterCreateRcptLineFromSalesLine and assigning SalesLine to the variant. AttemptCreateInspectionWithReceiptLine and CollectSourceItemTracking need no changes; both already handle transfer and sales lines.
2. New default source configuration in QltyAutoConfigure.Codeunit.al, next to the existing sales (:1067) and purchase (:1100) ones:
local procedure CreateDefaultWarehouseReceiptLineToTransferConfiguration()
var
QltyInspectSourceConfig: Record "Qlty. Inspect. Source Config.";
TempTransferLine: Record "Transfer Line" temporary;
TempWarehouseReceiptLine: Record "Warehouse Receipt Line" temporary;
begin
EnsureSourceConfigWithFilterExists(
WhseReceiptToTransferLineTok,
WhseReceiptToTransferLineDescriptionTxt,
Database::"Warehouse Receipt Line",
Database::"Transfer Line",
QltyInspectSourceConfig,
'WHERE(Source Type=CONST(5741))');
EnsureSourceConfigLineExists(
QltyInspectSourceConfig,
TempWarehouseReceiptLine.FieldNo("Source No."),
Database::"Transfer Line",
TempTransferLine.FieldNo("Document No."),
'');
EnsureSourceConfigLineExists(
QltyInspectSourceConfig,
TempWarehouseReceiptLine.FieldNo("Source Line No."),
Database::"Transfer Line",
TempTransferLine.FieldNo("Line No."),
'');
end;
There is no Source Subtype mapping line, unlike the purchase and sales variants: Transfer Line has no Document Type field, and Document No. plus Line No. identify the line. Three supporting touches complete it: two label declarations (for example WhseReceiptToTransferLineTok: Label 'WHSERCPTTOTRANSLINE', MaxLength = 20, Locked = true; and a matching description label), a call next to the two existing ones in the ensure-all orchestrator (:494), and a case branch in RecreateShippedDefaultSourceConfiguration (:343) so the restore actions added in #9605 can restore it. Without the shipped configuration those restore actions cannot help, which also makes this a supportability point.
An alternative worth considering instead of per-source subscribers: a single subscriber to "Whse. Create Source Document" OnAfterWhseReceiptLineInsert (src/Layers/W1/BaseApp/Warehouse/Request/WhseCreateSourceDocument.Codeunit.al:68), which fires for every source type, deriving the source line from the receipt line's Source Type/Subtype/No./Line No. That covers all current and future sources with one subscriber, at the cost of losing the typed source line parameter the current pattern uses.
I will provide a fix for a bug
- [x] I will provide a fix for a bug
:robot: AI triage completed. Product group, please validate the triage report (Microsoft internal access only, use Ctrl+Click to open in new tab).
Was this triage helpful? React with :thumbsup: or :thumbsdown: on this comment to provide feedback.
Coverage: issue-only analysis of https://github.com/microsoft/BCApps/issues/9977; no code change reviewed; no implementation or fix proposed (the issue's "Suggested fix" section was ignored); repository evidence searched: local NAV clone src/Apps/W1/Quality Management (app src for the receipt-create event subscribers and trigger enum, test src for warehouse-receipt tests, git log of codeunit 20411), GitHub issue search; not covered: Base App event call sites not re-read, no runtime/UI repro, test bodies not read in full, no ADO search, no translation/resource search.
BC impact analysis
Affected areas
- Quality Management (inspection generation rules, receiving integration)
- Warehouse (warehouse receipts)
- Inventory (transfer orders)
- Sales (sales return orders)
Reported severity and reproducibility: Unavailable functionality. No inspection is created at receipt creation for inbound transfers or sales returns, and nothing explains why. Reproducibility is specific and actionable (4 steps plus a working purchase reference case).
Customer-facing behavior: The "When Warehouse Receipt is created" trigger only works for receipt lines from purchase orders. Expected: inspections are created whatever the source document type, or the tooltip and docs say a source is out of scope.
Existing tests
- QltyTestsReceivingInteg.AttemptCreateInspectionWithReceiptLine_LotTracked_OnReceiptCreate (codeunit 139958)
- QltyTestsReceivingInteg.AttemptCreateInspectionWithReceiptLine (codeunit 139958)
- QltyTestsReceivingInteg.AttemptCreateInspectionOn_OnTransferReceivePost_Direct and _LotTracked_Direct (codeunit 139958): use the posting trigger, not receipt creation
- None would catch the reported behavior.
- Test codeunits identified: codeunit 139958 "Qlty. Tests - Receiving Integ."
Affected E2E scenarios
- Inbound transfer order to warehouse receipt to put-away: no inspection at receipt creation
- Sales return order to warehouse receipt: same gap
- Purchase order to warehouse receipt (reference case): works as reported
Existing tests for affected E2E scenarios
- Inbound transfer to warehouse receipt: None identified
- Sales return to warehouse receipt: None identified
- Purchase order to warehouse receipt: QltyTestsReceivingInteg.AttemptCreateInspectionWithReceiptLine_LotTracked_OnReceiptCreate (codeunit 139958) - partial coverage; does not detect the reported behavior
- E2E test codeunits identified: codeunit 139958 "Qlty. Tests - Receiving Integ."
Localizations impacted: None identified
First-party apps impacted: Quality Management
Potentially impacted first-party apps: None identified
Recommendation: Recommend: Approve - The issue has specific steps and a working reference case. No duplicate or prior fix was found, only related issues. No design or release constraint was found, though the issue itself allows the source being intentionally out of scope.
Suggested test buckets to run in DME
- Buckets: RunALIntegrationTests_W1_Extensions
- Unmapped / needs manual bucket assignment: none
A full regression and impact analysis was generated by scm-impact-agent.