AX / D365FO – Update Sales Line Qty and related quantites (RemainPhysical, etc..) and transactions X++

If you are updating sales line Qty using x++, use the below code to update lines and transactions related to that line.

salesLine salesLineUpdate;
salesLineUpdate.SalesQty += 5;
//Below line will update amounts etc after applying discounts.
salesLine::modifySalesQty(salesLineUpdate, SalesLineupdate.inventDim());
//Below line will update related transaction records
InventMovement::bufferSetRemainQty(salesLineUpdate);
salesLineUpdate.update();

Leave a comment