I have created a student table in dynamics ax. Now I have to make sure that when a new student record is created, a new customer must be created for each student record. How can I create this new customer record?
*This post is locked for comments
Hi Sajay,
Did you get this issue fixed in the meantime?
Hi Sanjay2507,
first, develop a form for creating new student.in this form , override save method and in this method add below code:
public class CustomerHelper { private void new() { } public static CustomerHelper construct() { return new CustomerHelper(); } public void createCustomer() { CustTable custTable; NumberSeq numberSeq; Name name ='Test Ca, Canada'; DirParty dirParty; DirPartyPostalAddressView dirPartyPostalAddressView; DirPartyContactInfoView dirPartyContactInfo; ; container conAttribute=["BusinessUnit","CostCenter","Department"]; container conAttributeValue=["001","007","022"]; /* Marks the beginning of a transaction. Necessary to utilize the method numRefCustAccount() */ ttsBegin; custTable.initValue(); try { //CustTable //numberSeq = NumberSeq::newGetNum(CustParameters::numRefCustAccount()); // custTable.AccountNum = numberSeq.num(); custTable.AccountNum = "US-00099"; custTable.CustGroup ='30'; custTable.Currency ='USD'; custTable.PaymTermId ='Net10'; custTable.PaymMode ='CHECK'; custTable.DefaultDimension=DefaultDimesnionHelper::createDefaultDimension(conAttribute,conAttributeValue); custTable.insert(DirPartyType::Organization, name); //DirParty /* Creates a new instance of the DirParty class from an address book entity that is represented by the custTable parameter. */ dirParty = DirParty::constructFromCommon(custTable); dirPartyPostalAddressView.LocationName ='Toronto, Canada '; dirPartyPostalAddressView.City ='Toronto'; dirPartyPostalAddressView.Street ='ar11ST'; dirPartyPostalAddressView.StreetNumber ='18'; dirPartyPostalAddressView.CountryRegionId ='ca'; dirPartyPostalAddressView.State ='test'; dirPartyPostalAddressView.IsPrimary = NoYes::Yes; // Fill address dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView); dirPartyContactInfo.LocationName ='Email Address'; dirPartyContactInfo.Locator ='test@gmail.com'; dirPartyContactInfo.Type = LogisticsElectronicAddressMethodType::Email; dirPartyContactInfo.IsPrimary = NoYes::Yes; // Fill Contacts dirParty.createOrUpdateContactInfo(dirPartyContactInfo); dirPartyContactInfo.LocationName ='Mobile Number'; dirPartyContactInfo.Locator ='416545665445'; dirPartyContactInfo.Type = LogisticsElectronicAddressMethodType::Phone; dirPartyContactInfo.IsPrimary = NoYes::Yes; // Fill Contacts dirParty.createOrUpdateContactInfo(dirPartyContactInfo); // Marks the end of transaction. ttsCommit; } catch(Exception::Error) { ttsAbort; throw Exception::Error; } } }
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156