Pages

April 24, 2013

Creating Vendors through X++ in AX 2012- PART II

Creating Vendors through X++ in AX 2012- PART II

Privious Post: 

--Create vendor and associate with vendor--

public void convertToVendor(VendorRequestCreate          _vendorRequestCreate)
{
    VendorRequestCreate                  vendorRequestCreate = VendorRequestCreate::find(_vendorRequestCreate.VendorNo,true);
    ;
if(_vendorRequestCreate.DirPartyType    == DirPartyBaseType::Person)
        vendTable.Party         = dirPerson.RecId;
else
        vendTable.Party         = dirOrganisation.RecId;
ttsBegin;
    vendTable.AccountNum    = NumberSeq::newGetNum(VendParameters::numRefVendAccount()).num();
ttsCommit;
if(vendTable.AccountNum == '')
        vendTable.AccountNum= int2str(_vendorRequestCreate.VendorNo);
    vendTable.Currency      = _vendorRequestCreate.CurrencyCode;
    vendTable.VendGroup     = _vendorRequestCreate.VendGroupId;
    vendTable.PaymTermId    = _vendorRequestCreate.PaymTermId;
    vendTable.DefaultDimension = _vendorRequestCreate.DefaultDimension;
    vendTable.OneTimeVendor = _vendorRequestCreate.OneTimeSupplier;
    vendTable.PaymMode      = _vendorRequestCreate.PaymMode;
    vendTable.BankAccount   = _vendorRequestCreate.BankAccount;
    vendTable.WI_Remarks    = _vendorRequestCreate.Remarks;
    vendTable.WI_DepartmentEmail = _vendorRequestCreate.DepartmentEmail;
    vendTable.insert();
    this.createPostalAddress(_vendorRequestCreate);
    this.createCommAddress(_vendorRequestCreate);
    this.createBankDetails(_vendorRequestCreate,vendTable.AccountNum);
    this.createContact(_vendorRequestCreate,vendTable.Party);
if(vendTable.RecId)
    {
        vendorRequestCreate.VendAccount = vendTable.AccountNum;
        vendorRequestCreate.update();
        info(strFmt('Vendor %1 has been successfully created',vendTable.AccountNum));
    }
}

-Harry

No comments:

Post a Comment

Thanks