Customize Purchase order approval status
In the case of D365 Finance and Operations when you approve purchase requisition by default system creates Purchase order with approval status as “Approved” as follows
To change this default behavior of system such that once purchase requisition is approved the approval status of the purchase order as a draft you can use the following class
class CFSPOStatus
{
/// <summary>
///
/// </summary>
/// <param name=”args”></param>
[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;
}
}and your final result looks like
And after changing status you can apply your own purchase order workflow on it.
For purchase order workflow you can refer to my blog
Related posts:
From Client Secrets to Certificate-Based Authentication: Building a Secure Integration with Azure Ke...

From Multiple Data Sources to Azure Databricks: A Zero-Downtime Power BI Report Data Migration for F...
Using AI for Data Discipline That Drives Better AI Outcomes



