How to update PO Vendor Account

Job for updating the Vendor account and update PO


 static void updatePO_VendorAccount(Args _args)
{
    PurchTable po;
    PurchLine pl;
    VendTable vT;

    VendPackingSlipJour vendP;

    PurchId poNum;
    DialogField dpo;

    VendAccount vendor;
    DialogField dvendor;

    Dialog d;
    d = new Dialog();
    d.caption("Choose a PO to update and the vendor account");

    dpo = d.addField(extendedTypeStr(PurchId));
    dvendor = d.addField(extendedTypeStr(VendAccount));

    d.run();

    poNum = dpo.value();
    vendor = dvendor.value();

    if(d.closedOk() && poNum && vendor && Box::yesNo(strFmt("You are about to update      PO: %1 to Vendor: %2. Do you wish to continue?", poNum, vendor), DialogButton::No))
{
        select firstOnly forUpdate po
            where po.PurchId == poNum;

        select firstOnly vT
            where vT.AccountNum == vendor;

        ttsBegin;
        po.initFromVendTable(vT);
        po.doUpdate();

        update_recordSet pl
            setting VendAccount = vendor
            where pl.purchid == poNum;

        update_recordSet vendP
            setting OrderAccount = vendor
            where vendP.PurchId == poNum;

        ttsCommit;

        info("Mission Complete");
    }
}

Comments

Popular posts from this blog

D365FO - Data integration by OData

Create or Update Product attributes using X++ in D365 F&O

Layers concept in D365