Purchase order confirmation using X++ code

In this article we will be focusing on confirmation of a purchase order using X++ code.

Confirm Purchase Order

First we will see how do we confirm purchase order from front end of Microsoft Finance and Operations and then we’ll jump over to do that process through X++ code.

I will list down the steps to do that sequentially.

  1. Firstly I need to select the purchase order which I want to confirm and the go to Purchase tab and then click Confirm button as seen in below image.
  2. It’ll take some time while confirming the purchase order.
  3. Now as you see after the operation is complete this purchase order is now confirmed.

Confirm Purchase Order using X++ code

Now we will see how to do that process through X++ code.

Use this given method below to confirm a purchase order in X++ using PurchFormLetter class.

The parameter passed to this method is purchase order id which needs to be confirmed.

public void purchaseOrderConfirm(PurchId _purchId)
    {
        PurchFormLetter             purchFormLetter;
        PurchFormletterParmData     purchFormLetterParmData;
        PurchParmUpdate             purchParmUpdate;
        PurchParmTable              purchParmTable;
        PurchTable                  purchTable;

        purchTable = PurchTable::find(_purchId);

        ttsBegin;

        purchFormLetterParmData = PurchFormletterParmData::newData(DocumentStatus::PurchaseOrder,
                                                                   VersioningUpdateType::Initial);

        purchFormLetterParmData.parmOnlyCreateParmUpdate(true);
        purchFormLetterParmData.createData(false);
        purchParmUpdate = purchFormLetterParmData.parmParmUpdate();

        purchParmTable.clear();
        purchParmTable.TransDate                = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());
        purchParmTable.DocumentDate             = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());
        purchParmTable.Ordering                 = DocumentStatus::PurchaseOrder;
        purchParmTable.ParmJobStatus            = ParmJobStatus::Waiting;
        purchParmTable.PurchId                  = purchTable.PurchId;
        purchParmTable.PurchName                = purchTable.PurchName;
        purchParmTable.DeliveryName             = purchTable.DeliveryName;
        purchParmTable.DeliveryPostalAddress    = purchTable.DeliveryPostalAddress;
        purchParmTable.OrderAccount             = purchTable.OrderAccount;
        purchParmTable.CurrencyCode             = purchTable.CurrencyCode;
        purchParmTable.InvoiceAccount           = purchTable.InvoiceAccount;
        purchParmTable.ParmId                   = purchParmUpdate.ParmId;
        purchParmTable.insert();

        purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
        purchFormLetter.transDate(DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));
        purchFormLetter.proforma(false);
        purchFormLetter.specQty(PurchUpdate::All);
        purchFormLetter.purchTable(purchTable);

        purchFormLetter.parmParmTableNum(purchParmTable.ParmId);
        purchFormLetter.parmId(purchParmTable.ParmId);
        purchFormLetter.purchParmUpdate(purchFormLetterParmData.parmParmUpdate());
        purchFormLetter.run();

        ttsCommit;
    }

Thank you for reading this article hope you find it useful.

Omar Iqbal

Technical Consultant

References:

  1. https://dynamicsaxinsight.wordpress.com/2015/12/28/ax-2012-confirm-purchase-order-in-xpp/
  2. https://d365ffo.com/2021/04/01/d365ffo-ax-2012-confirm-purchase-order-in-x/
  3. http://axhelper.com/?p=6019
Total
0
Shares
5 comments
  1. Hello my friend! I wish to say that this post is amazing, nice written and come with almost all important infos. I would like to peer more posts like this .

  2. Amazing! This blog looks exactly like my old one! It’s on aentirely different topic but it has pretty much the same layout and design. Superb choice of colors!my blog post – weight loss goals

Comments are closed.

Previous Article

Create and post inventory ownership change journal using X++ code

Next Article

Sales order confirmation using X++ code

Related Posts