Skip to main content

Purchase order approval status customization

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

Comments

Popular posts from this blog

Import Database from UAT/Production to cloud-hosted or dev environment | D365 Finance and operations

Update: If following method is not working have a look at this  Changes in SQL Script to restore bacpac file for D365FO Many times to debug the Production environment issues we might need live data to address that issue in such case first of all we need to refresh the UAT/Sandbox database with the Production environments database and then afterward we need to export the UAT database to the Asset library from where we can get bacpac file for that UAT database which is then to be imported in your cloud-hosted or one-box environment. This blog and video demonstration will help you to restore your production or UAT database to a cloud-hosted environment. Step 1: Rename existing db  In this step, we need to rename the existing AxDB for safety purposes. Just go to the SSMS application and execute the following command:-   ALTER DATABASE [ip_ent_site] SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO ALTER DATABASE [ip_ent_site] MODIFY NAME = [ip_ent_site_new] GO ALTER DATABASE [ip_ent...

Changes in SQL Script to restore bacpac file for D365FO

There are changes in SQL db import it needs additional parameters now  Connection Security Improvements in SqlPackage 161 | Microsoft Community Hub otherwise it will throw following error *** Changes to connection setting default values were incorporated in a recent release.  More information is available at https://aka.ms/dacfx-connection *** Error importing database:Could not import package. Unable to connect to target server 'localhost'. Please verify the connection information such as the server name, login credentials, and firewall rules for the target server. A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.) The certificate chain was issued by an authority that is not trusted. *** The settings for connection encryption or server certificate trust may lead to connection failure if the server is not properl...

Regression Suite Automation Tool (RSAT) implementation and configuration for Finance and Operations

Purpose: The Regression suite automation tool (RSAT) significantly reduces the time and cost of user acceptance testing. This tool enables functional power users to record business tasks using the Finance and Operations Task recorder and convert these recordings into a suite of automated tests without the need to write source code. Test libraries are stored and distributed in Lifecycle Services (LCS) using the Business Process Modeler (BPM) libraries. These libraries are also fully integrated with Azure DevOps Services (Azure DevOps) for test execution, reporting and investigation. Test parameters are decoupled from test steps and stored in Microsoft Excel files. Video demonstration Prerequisites: Dynamics 365 for Finance and Operations test environment (Demo or tier 2 UAT environment  Excel   Azure DevOps: You will need an Azure DevOps Test Manager or Test Plans license. For example, if you have a Visual Studio Enterprise subscription, you already have a l...