Change RFQ purchase order status as draft insted of default approved
When we create purchase order using RFQ its default approval status will be approved.
To change that status to draft write following code where we will change its status to draft.
create new class and add following code
class CFSPOStatusRfq
{
[PostHandlerFor(classStr(PurchAutoCreate_RFQ), methodStr(PurchAutoCreate_RFQ, endUpdate))]
public static void PurchAutoCreate_PurchReq_Post_endUpdate(XppPrePostArgs args)
{
//PurchTable purchTable = args.getThis(‘purchTable’);
PurchAutoCreate_RFQ purchReq = args.getThis() as PurchAutoCreate_RFQ;
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;
}
}
Related posts:

Dynamics 365 Business Central Data Migration: Common Mistakes, Risks, and How to Avoid Them

How Dynamics 365 Business Central Automates Receivables Account Selection for Multi-Product Finance ...
How Dynamics 365 Business Central Automates Receivables Account Selection for Multi-Product Finance ...

