Customize Purchase order approval status | CloudFronts

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();
        select forupdate purchTablenew where purchTableNew.PurchId == purchTable.PurchId;
        if(purchTablenew && purchTablenew.DocumentState == VersioningDocumentState::Approved)
            purchTablenew.DocumentState = VersioningDocumentState::Draft;

}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

Share Story :

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.