Monday, November 26, 2018

Remove reservations and markings from a sales orders in Ax 2012/ D365 F&O x++



Below is the code where we can unreserve the inventory from sales orders/sales order lines.

Paste the below in a JOB

Static void Tutorial_UnreserveSalesTable(Args _args) { InventTrans inventTrans; InventTransOrigin inventTransOrigin; SalesLine salesLine; InventMovement inventMovement; InventUpd_Reservation inventUpd_Reservation ; SalesId SalesId = "001260";//<--- Send/get sales id here // Remove reservations and markings on a reserved salesorder while select inventTrans where inventTrans.StatusReceipt == StatusReceipt::None && (inventTrans.StatusIssue == StatusIssue::ReservPhysical || inventTrans.StatusIssue == StatusIssue::ReservOrdered) exists join inventTransOrigin where inventTransOrigin.RecId == inventTrans.InventTransOrigin exists join salesLine where salesLine.InventTransId == inventTransOrigin.InventTransId && SalesLine.SalesId == SalesId { if (inventTrans.MarkingRefInventTransOrigin) { InventTransOrigin::deleteMarking(inventTrans.MarkingRefInventTransOrigin, inventTrans.InventTransOrigin, -inventTrans.Qty, true); InventTransOrigin::deleteMarking(inventTrans.InventTransOrigin, inventTrans.MarkingRefInventTransOrigin, inventTrans.Qty, true); } if (inventTrans.StatusIssue == StatusIssue::ReservPhysical || inventTrans.StatusIssue == StatusIssue::ReservOrdered) { Inventmovement = inventTrans.inventmovement(true); inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventmovement,inventTrans.inventDim(), -1 * inventTrans.Qty, false); inventUpd_Reservation.updatenow(); } } }


@Rahul

2 comments:

Power Automate vs Azure Logic Apps vs Azure Data Factory: What They Are, When to Use Them, and How to Integrate Non-Microsoft Systems

  In today’s cloud-first, API-driven enterprise landscape, automation and integration have become vital pillars of operational agility. Micr...