Create a customer through code in JOB x++

 Create a customer through code


static void JobTOCreateCustomer(Args _args)

{

        CustTable                       custTable;

        NumberSeq                       numberSeq;

        Name                            name                    =   'Wrexim Technologies';


        DirParty                        dirParty;

        DirPartyPostalAddressView       dirPartyPostalAddressView;

        DirPartyContactInfoView         dirPartyContactInfo;


        container                       conAttribute            =   ["BusinessUnit","CostCenter","Department"];

        container                       conAttributeValue       =   ["001","007","022"];


        ttsBegin;

        custTable.initValue();


        try

        {


            //numberseq                                           =   numberseq::newgetnum(custparameters::numrefcustaccount());

            //custTable.AccountNum                                =   numberSeq.num();

            custTable.AccountNum                                =   "AS-00001";

            custTable.CustGroup                                 =   '30';

            custTable.Currency                                  =   'INR';

            custTable.PaymTermId                                =   'Net10';

            custTable.PaymMode                                  =   'CHECK';

           // custTable.DefaultDimension                          =   DefaultDimension::createDefaultDimension(conAttribute,conAttributeValue);

            custTable.insert(DirPartyType::Organization, name);


            dirParty                                            =   DirParty::constructFromCommon(custTable);


            dirPartyPostalAddressView.LocationName              =   'Microsoft Dynamics AX/d365';

            dirPartyPostalAddressView.City                      =   'Hyd';

            dirPartyPostalAddressView.Street                    =   'Jublee Enclave';

            dirPartyPostalAddressView.StreetNumber              =   '18';

            dirPartyPostalAddressView.CountryRegionId           =   'IND';

            dirPartyPostalAddressView.State                     =   'Telangana';

            dirPartyPostalAddressView.IsPrimary                 =   NoYes::Yes;


            dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);



            dirPartyContactInfo.LocationName                    =   'Email Address';

            dirPartyContactInfo.Locator                         =   'anilkumargoud24@gmail.com';

            dirPartyContactInfo.Type                            =   LogisticsElectronicAddressMethodType::Email;

            dirPartyContactInfo.IsPrimary                       =   NoYes::Yes;


            dirParty.createOrUpdateContactInfo(dirPartyContactInfo);



            dirPartyContactInfo.LocationName                    =   'Mobile Number';

            dirPartyContactInfo.Locator                         =   '8688221447';

            dirPartyContactInfo.Type                            =   LogisticsElectronicAddressMethodType::Phone;

            dirPartyContactInfo.IsPrimary                       =   NoYes::Yes;


            dirParty.createOrUpdateContactInfo(dirPartyContactInfo);


            ttsCommit;

        }

        catch(Exception::Error)

        {

            ttsAbort;

            throw Exception::Error;

        }

    info("Customer is created");

}




==================================================================================================================


website: https://d365technext.blogspot.com/2018/09/create-customer-using-x-d365fo-ax-2012.html


==================================================================================================================

Comments