"Item Tracking Doc. Management".FindInvoiceEntries (External function) leaves the filter on the By-Reference-Parameter)
====== PROBLEM DESCRIPTION: "Item Tracking Doc. Management".FindInvoiceEntries (External function) leaves the filter on the By-Reference-Parameter Codeunit 6503 "Item Tracking Doc. Management", [External] function FindInvoiceEntries(). It’s a standard global function to retrieve item tracking information based on a posted sales invoice line. It retrieves item tracking information from ItemLedgerEntries and fills a temporary Tracking Specification Buffer but leaves the filter on the By-Reference-Parameter. + The same problem for FindShptRcptEntries
BUSINESS IMPACT: System does not work as expected.
BEFORE YOU START:
STEPS TO REPRO BC 14.x (W1) CU04 1-Create local Docker container: BCONPREM-144-W1 I used script:
===
$accept_eula = $true
$containername = 'BCONPREM-144-W1'
$navdockerimage = 'mcr.microsoft.com/businesscentral/onprem:14.4.35602.0-w1'
$credential = get-credential -UserName $env:USERNAME -Message "Using Windows Authentication. Please enter your Windows credentials."
$licenseFile = "D:\_DEVDOCKER\build.flf"
New-BCContainer -accept_eula:$accept_eula `
-containername $containername `
-auth Windows `
-Credential $credential `
-includeCSide `
-usessl:$false `
-updateHosts `
-licenseFile $licenseFile `
-shortcuts Desktop `
-imageName $navdockerimage `
-includeAL `
-memoryLimit 10G `
-alwaysPull
=== 2-Create a new ‘Purchase Order’ Header:
- Vendor = 10000
- Vendor Invoice No. = 1 Line:
- Type = Item
- No. = 80102-T // “Item Tracking Code” = SNALL, no entries for this item
- Location Code = BLUE
- Quantity = 3 Press Line \ Item Tracking Lines, add 3 lines: SN1, SN2, SN3 Post ‘Purchas Order’
3-Create a new ‘Sales Invoice’ Header:
- Customer = 10000 Line:
- Type = Item
- No. = 80102-T
- Location Code = BLUE
- Quantity = 3
Press Line \ Related Information \ Item Tracking Lines, add 3 lines: SN1, SN2, SN3
Post ‘Sales Invoice’

4-Create a small AL extension: // Create a call for the external function FindInvoiceEntries() of Cod6503 "Item Tracking Doc. Management“
pageextension 50100 CustomerListExt extends "Customer List"
{
trigger OnOpenPage();
var
SalesInvLine: Record "Sales Invoice Line";
TempTrackingSpecBuffer: Record "Tracking Specification" temporary;
ItemTrackingDocMgt: Codeunit "Item Tracking Doc. Management";
begin
//Message('App published: Hello world');
SalesInvLine.SetRange("No.",'80102-T');
SalesInvLine.FindLast();
ItemTrackingDocMgt.FindInvoiceEntries(TempTrackingSpecBuffer,DATABASE::"Sales Invoice Line", 0,
SalesInvLine."Document No.", '', 0, SalesInvLine."Line No.",
SalesInvLine.Description);
Message('Test 1: %1', TempTrackingSpecBuffer.Count);
TempTrackingSpecBuffer.Reset();
Message('Test 2: %1', TempTrackingSpecBuffer.Count);
end;
}
===

5-Run the code, you get the following Messages: Test 1: 1 Test 2: 3 The FindInvoiceEntries-function sets a filter to the TempTrackingSpecBuffer-Variable (by reference) which is not reset, hence you don’t get the correct buffer.

ACTUAL RESULTS "Item Tracking Doc. Management".FindInvoiceEntries (External function) leaves the filter on the By-Reference-Parameter
PARTNER EXPECTED RESULTS (Customer / Partner / SP) The partner suggest fix:

TROUBLESHOOTING On standard CRONUS There is not a button a user can press where this case would happen, but the function is declared as external and therefore meant as an API to be extended in customization and extension scenarios.
ADDITIONAL TECHNICAL INFORMATION Standard system has RESET a bit later in the code:

I’ve checked the code history: COD 6503 has been added for NAV 2016 (9.0) release (~ August 2015) ), the function FindInvoiceEntries does not change since this period…
DEV team just add an external tag ~ October 2018 287388 - [Event Request][GitHub #124] [Function Expose] Codeunit 6503 - FindShptRcptEntries, FindInvoiceEntries (106) https://github.com/microsoft/ALAppExtensions/issues/124 + The same problem for FindShptRcptEntries

======
Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. We will update this issue with information about availability.
Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. We will update this issue with information about availability.