Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

creating a new customer

Posted on by Microsoft Employee

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

  • Hossein.K Profile Picture
    Hossein.K 6,642 on at
    RE: creating a new customer

    Hi Sajay,

    Did you get this issue fixed in the meantime?

  • Suggested answer
    Hossein.K Profile Picture
    Hossein.K 6,642 on at
    RE: creating a new customer

    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;
            }
        }
    
    
    }
    


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans