[Bug]: [Quality Management] Tracking specification buffer defects in HandleOnAfterPurchRcptLineInsert
@JakovljevicDusan is already working on this.
Since Sep 3, 2026.
- Dominant language
- AL
- Stars
- 683
- Forks
- 459
- Avg merge
- 3d 26m
- Merged PRs (30d)
- 633
Description
Describe the issue
Two defects in HandleOnAfterPurchRcptLineInsert, codeunit 20411 "Qlty. Receiving Integration" (src/Apps/W1/Quality Management/app/src/Integration/Receiving/QltyReceivingIntegration.Codeunit.al), the subscriber to Purch.-Post OnAfterPurchRcptLineInsert.
1. The filter cleanup clears a field that was never filtered and leaves the applied filter in place.
The filters applied to the shared var TempTrackingSpecification buffer start at :61:
TempTrackingSpecification.SetFilter("Quantity Handled (Base)", '<>0');
The cleanup block at :89-94 clears "Qty. to Invoice (Base)" (never filtered) instead of "Quantity Handled (Base)":
TempTrackingSpecification.SetRange("Qty. to Invoice (Base)");
TempTrackingSpecification.SetRange("Source ID");
...
TempTrackingSpecification is a var parameter owned by codeunit 80. The cleanup block exists precisely to hand the buffer back clean, and this typo defeats it: after the subscriber returns, posting continues with a "Quantity Handled (Base)" <> 0 filter still applied to its own buffer.
2. A single-record buffer is built and then not passed.
In the tracking loop (:79-86), TempSingleBufferTrackingSpecification is populated from the current record, inserted, and SetRecFilter() is applied, but the call on :85 passes the full multi-record buffer instead:
repeat
Clear(TempSingleBufferTrackingSpecification);
TempSingleBufferTrackingSpecification := TempTrackingSpecification;
TempSingleBufferTrackingSpecification.Insert(false);
TempSingleBufferTrackingSpecification.SetRecFilter();
AttemptCreateInspectionWithPurchaseLineAndTracking(PurchaseLine, PurchaseHeader, TempTrackingSpecification);
until TempTrackingSpecification.Next() = 0;
The zero-tracking branch a few lines above (:73-75) passes TempSingleBufferTrackingSpecification, which makes the intent clear: each iteration should hand over the isolated single tracking record. As written, the single-record buffer is dead weight; either the call should pass it, or the buffer, insert, and SetRecFilter should be removed.
Expected behavior
The cleanup clears exactly the filters that were set ("Quantity Handled (Base)" included), and the loop passes the single-record buffer it builds, or does not build it.
Steps to reproduce
Defect 1 is visible by reading :61 against :89. Defect 2 by comparing :73-75 with :79-86. Both confirmed present on current main.
Additional context
Both defects are in the same procedure and would naturally be fixed in one small PR. Suggested corrections:
For defect 1, clear the field that was actually filtered:
TempTrackingSpecification.SetRange("Quantity Handled (Base)");
instead of TempTrackingSpecification.SetRange("Qty. to Invoice (Base)"); at :89. The "Buffer Status" filter set at :62 is already cleared correctly at :94.
For defect 2, pass the single-record buffer the loop builds:
AttemptCreateInspectionWithPurchaseLineAndTracking(PurchaseLine, PurchaseHeader, TempSingleBufferTrackingSpecification);
instead of passing TempTrackingSpecification at :85, matching the zero-tracking branch at :75. If passing the full buffer positioned on the current record is intentional, then the single-record buffer, its Insert and its SetRecFilter() are dead code and should be removed instead.
I will provide a fix for a bug
- I will provide a fix for a bug
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.