Change Purchase Order Status To Draft After Release Purchase Req
Mohamed Zakarya
IT Manager |Application Manager| ERP consultant | D365FO | AX 2012 | AX 2009 | Power BI | SSRS |Forms | Reports Design | development X++ | Cost Analysis| Inventory | Production | Procurement | General Ledger |
class CFSPOStatus
{
[PostHandlerFor(classStr(PurchAutoCreate_PurchReq), methodStr(PurchAutoCreate_PurchReq, endUpdate))]
public static void PurchAutoCreate_PurchReq_Post_endUpdate(XppPrePostArgs args)
{
//PurchTable purchTable = args.getThis(‘purchTable’);
PurchAutoCreate_PurchReq purchReq = args.getThis() as PurchAutoCreate_PurchReq;
PurchTable purchTable, purchTablenew;
purchTable = purchReq.parmPurchTable();
ttsbegin;
select forupdate purchTablenew where purchTableNew.PurchId == purchTable.PurchId;
if(purchTablenew && purchTablenew.DocumentState == VersioningDocumentState::Approved)
{
purchTablenew.DocumentState = VersioningDocumentState::Draft;
purchTablenew.update();
}
ttscommit;
}
}