Tuesday, June 10, 2014

Create Customer by Code in Ax 2012


This is a Code to create Customer in Axapta 2012. You can try below code in job.

 custTable _custTable;  
 numberSeq _numberSeq;  
 name _name ='Test Customer';  
 dirParty _dirParty;  
 dirPartyPostalAddressView _dirPartyPostalAddressView;  
 dirPartyContactInfoView _dirPartyContactInfo;  
 ;  
 _custTable.initValue();  
 _numberSeq = _numberSeq::newGetNum(CustParameters::numRefCustAccount());  
 _custTable.AccountNum = _numberSeq.num();  
 _custTable.CustGroup ='CG';  
 _custTable.Currency ='INR';  
 _custTable.PaymTermId ='01';  
 _custTable.PaymMode ='CHQ1';  
 _custTable.insert(dirPartyType::Organization, _name);  
 _dirParty = dirParty::constructFromCommon(_custTable);  
 _dirPartyPostalAddressView.Location_name ='TT ';  
 _dirPartyPostalAddressView.City ='SS';  
 _dirPartyPostalAddressView.Street ='TTS';  
 _dirPartyPostalAddressView.StreetNumber ='23';  
 _dirPartyPostalAddressView.CountryRegionId ='DFD';  
 _dirPartyPostalAddressView.State ='DE';  
 _dirParty.createOrUpdatePostalAddress(_dirPartyPostalAddressView);  
 _dirPartyContactInfo.Location_name ='T';  
 _dirPartyContactInfo.Locator ='424234234';  
 _dirPartyContactInfo.Type = LogisticsElectronicAddressMethodType::Phone;  
 _dirPartyContactInfo.IsPrimary = NoYes::Yes;  
 _dirParty.createOrUpdateContactInfo(_dirPartyContactInfo);