Thursday 4 February 2016

How to create Customer through code in Ax 2012

static void Raj_CustomerCreate(Args _args)
{
    CustTable       custTable;
    NumberSeq       numseq;
    Name            name ="SouthSide Street LTDA";
   
    DirParty        dirParty;
    DirPartyPostalAddressView   dirPartyPostalAddressView;
    dirpartypostaladdressview
 
    DirPartyContactInfoView     dirPartyContactInfo;
   
    ttsBegin;
    custTable.initValue();
    numseq  = NumberSeq::newGetNum(CustParameters::numRefCustAccount());
    custTable.AccountNum = 'HYD-100';
    custTable.CustGroup  = '20';
    custTable.Currency   = 'INR';
    custTable.PaymTermId = 'Net-120';
    custTable.PaymMode   = 'Cheque';
    custTable.insert(DirPartyType::Organization , name);
   
    dirParty = DirParty::constructFromCommon(custTable);
    dirPartyPostalAddressView.LocationName      ='HeadQuarters ';
    dirPartyPostalAddressView.City              ='São Paulo';
    dirPartyPostalAddressView.Street            ='4th Avenue';
    dirPartyPostalAddressView.StreetNumber      ='18';
    dirPartyPostalAddressView.CountryRegionId   ='BRA';
    dirPartyPostalAddressView.State             ='SP';
    dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);

    dirPartyContactInfo.LocationName    ='SouthStreet Contact Phone';
    dirPartyContactInfo.Locator         ='551291165341';
    dirPartyContactInfo.Type            = LogisticsElectronicAddressMethodType::Phone;
    dirPartyContactInfo.IsPrimary       = NoYes::Yes;

        // Fill Contacts
    dirParty.createOrUpdateContactInfo(dirPartyContactInfo);

   
    ttsCommit;
   

}

No comments:

Post a Comment