From 7dff0858bc453835264636df4ce5b927c5866f70 Mon Sep 17 00:00:00 2001 From: Jeffrey Bulanadi Date: Tue, 21 Apr 2026 16:42:36 +0800 Subject: [PATCH] Fix: Restore Completely Shipped after RedistributeInvoiceDiscounts in Sales Order API pages RedistributeInvoiceDiscounts called in OnAfterGetRecord triggers an OnAfterModifySalesLine event handler (UpdateCompletelyShipped) that copies spurious filters from the SalesLine record and incorrectly evaluates IsEmpty() as true, causing Completely Shipped to be set to true regardless of actual shipment status. Save and restore Rec.'Completely Shipped' around the call in both APIV1 - Sales Orders and APIV2 - Sales Orders pages so that the value returned by the API reflects the actual state of sales lines. Fixes #29071 --- Apps/W1/APIV1/app/src/pages/APIV1SalesOrders.Page.al | 7 ++++++- Apps/W1/APIV2/app/src/pages/APIV2SalesOrders.Page.al | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Apps/W1/APIV1/app/src/pages/APIV1SalesOrders.Page.al b/Apps/W1/APIV1/app/src/pages/APIV1SalesOrders.Page.al index 254a581d1c..530017b224 100644 --- a/Apps/W1/APIV1/app/src/pages/APIV1SalesOrders.Page.al +++ b/Apps/W1/APIV1/app/src/pages/APIV1SalesOrders.Page.al @@ -451,10 +451,15 @@ page 20028 "APIV1 - Sales Orders" } trigger OnAfterGetRecord() + var + IsCompletelyShipped: Boolean; begin SetCalculatedFields(); - if HasWritePermission then + if HasWritePermission then begin + IsCompletelyShipped := Rec."Completely Shipped"; GraphMgtSalesOrderBuffer.RedistributeInvoiceDiscounts(Rec); + Rec."Completely Shipped" := IsCompletelyShipped; + end; end; trigger OnDeleteRecord(): Boolean diff --git a/Apps/W1/APIV2/app/src/pages/APIV2SalesOrders.Page.al b/Apps/W1/APIV2/app/src/pages/APIV2SalesOrders.Page.al index acf7eff5df..90ccdfe0e6 100644 --- a/Apps/W1/APIV2/app/src/pages/APIV2SalesOrders.Page.al +++ b/Apps/W1/APIV2/app/src/pages/APIV2SalesOrders.Page.al @@ -613,10 +613,15 @@ page 30028 "APIV2 - Sales Orders" } trigger OnAfterGetRecord() + var + IsCompletelyShipped: Boolean; begin SetCalculatedFields(); - if HasWritePermission then + if HasWritePermission then begin + IsCompletelyShipped := Rec."Completely Shipped"; GraphMgtSalesOrderBuffer.RedistributeInvoiceDiscounts(Rec); + Rec."Completely Shipped" := IsCompletelyShipped; + end; end; trigger OnDeleteRecord(): Boolean