Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Release Customer for Specified Legal Entities

Posted on by Microsoft Employee

Hi Friends,

             How can we create Customer for an single legal entity in ax 2012 through x++ coding .

Thanks& Regards,

padmapriya.v

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Release Customer for Specified Legal Entities

    Hi Sukrut,

                    I have used your Change company concept in the x++ code , 

    static void JobCreateCustomer (Args _args)

    {

    custTable _custTable;
    numberSeq _numberSeq;
    name _name ='i82';

    DirPartyTable dirPartyTable;
    dirParty _dirParty;
    dirPartyPostalAddressView _dirPartyPostalAddressView;
    dirPartyContactInfoView _dirPartyContactInfo;

    ;

    changecompany ("USSI")
    _custTable.initValue();


    _numberSeq = numberSeq::newGetNum(CustParameters::numRefCustAccount());

    _custTable.AccountNum = "1234";//_numberSeq.num();

    _custTable.CustGroup ='gh';

    _custTable.Currency ='INR';

    _custTable.PaymTermId ='89';

    _custTable.PaymMode ='C12';

    _custTable.insert();

    _dirParty = dirParty::constructFromCommon(_custTable);
    _dirPartyPostalAddressView.City ='ui';
    _dirPartyPostalAddressView.Street ='oiut';
    _dirPartyPostalAddressView.StreetNumber ='29';
    _dirPartyPostalAddressView.CountryRegionId ='hd';
    _dirPartyPostalAddressView.State ='DE';
    _dirParty.createOrUpdatePostalAddress(_dirPartyPostalAddressView);
    _dirPartyContactInfo.Locator ='shdgfjsd';
    _dirPartyContactInfo.Type = LogisticsElectronicAddressMethodType::Phone;
    _dirPartyContactInfo.IsPrimary = NoYes::Yes;

    _dirParty.parmName('Meera');
    // _dirPartydirParty.parmName('Teera')
    _dirParty.createOrUpdateContactInfo(_dirPartyContactInfo);

    dirPartyTable = DirPartyTable::findRec(_custTable.Party,true);
    dirPartyTable.Name = 'Meera';
    dirPartyTable.update();

    //_dirPartyPostalAddressView.Location_name ='TT';
    //_dirParty = dirParty::constructFromCommon(_custTable);
    }

    But ill getting error like "Cannot create a record in Customers (CustTable). Insert operations are not allowed across companies. Please use changecompany keyword to change the current company before inserting the record."

    Please suggest me an solution.

    Thanks & Regards, 

    padmapriya.v

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Release Customer for Specified Legal Entities

    Hi Sukrut ,

                      Thanks for your reply , But its not my question .

    For example , if we are in legal entity: "THMF" and i need to create a customer and assign the customer for only these to Legal entity : "THMF" & "USSI" using x++ how do i create in it.

    Thanks & regards,

    padmapriya.v

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