Cannot Cancel or Change a Sales Order Line: A Related Warehouse Shipment Line Exists
The Sales Line cannot be deleted when a related Warehouse Shipment Line exists.What It Means
A customer cancels a line or the whole order, or a Shopify/EDI update tries to remove a line. Business Central refuses, because the line is already on a warehouse shipment. The warehouse (your own or a 3PL fed from warehouse shipments) has the instruction to ship it. A related error appears if you change the line instead of deleting it: 'Quantity must not be changed when a Warehouse Shipment Line for this Sales Line exists'. The same check covers Type, No., Variant Code, Location Code, Unit of Measure Code, Drop Shipment, Qty. to Ship and Shipment Date.
Root Cause
When a sales line is on a warehouse shipment, codeunit 'Sales Warehouse Mgt.' blocks a delete (SalesLineDelete calls RaiseCannotBeDeletedErr) and blocks changes to key fields (SalesLineVerifyChange). This is a control: the sales side must not change an order while the warehouse works on it. It fires even if nothing is picked or shipped yet. Integrations that cancel or edit orders automatically (Shopify order edits, EDI 860 change orders, 3PL connectors) hit it when they run after the warehouse shipment was created.
Step-by-Step Fix
- Note the sales order number and line number from the error or from the integration log.
- Open the sales order. Choose Related > Warehouse > Warehouse Shipment Lines (or search 'Warehouse Shipments' and filter on the order number) to find the shipment.
- Check with the warehouse or 3PL that nothing is physically picked or packed for that line. If a pick exists, delete or register the pick first; if a 3PL received the order, cancel it in the 3PL portal first.
- Open the warehouse shipment. Delete the line for this sales line, or delete the whole shipment if it only holds this order.
- Go back to the sales order. If its Status is Released, choose Reopen.
- Delete or change the sales line (or rerun the integration step that failed).
- Release the order again and choose Create Warehouse Shipment if the rest of the order must still ship.
- To stop repeats: have the integration check for warehouse shipment lines before it edits an order, and send late changes to a person instead of failing in the job queue.
Verification Steps
Sources & References
- https://github.com/microsoft/BCApps/blob/e48e2d94b13dc61a88b9a1811732ca4fbc36e6c2/src/Layers/W1/BaseApp/Warehouse/Request/WhseValidateSourceLine.Codeunit.al#L31-L32
- https://github.com/microsoft/BCApps/blob/e48e2d94b13dc61a88b9a1811732ca4fbc36e6c2/src/Layers/W1/BaseApp/Sales/Document/SalesWarehouseMgt.Codeunit.al#L123-L170
- https://forum.mibuso.com/discussion/comment/108045
Early Access · 30-Day Sandbox Pilot
Stop Order Sync Failures Before Customers Notice
The Order Flow Doctor monitors Microsoft Dynamics 365 Business Central order flows across Shopify, EDI (TrueCommerce, SPS), 3PLs, and carriers. Get automated root-cause diagnosis and one-click fixes.