Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 175888

RE: Creating a new Party record (for the purpose of creating a new Prospect) via X++

$
0
0

I think I finally got it created by the following script

staticvoid JobCreateProspect (Args _args)

{

    smmBusRelTable               prospect;

    NumberSeq                    numberSeq;

    Name                         name ='SouthSide Street LTDA';

 

    DirParty                        dirParty;

    DirPartyPostalAddressView       dirPartyPostalAddressView;

    DirPartyContactInfoView         dirPartyContactInfo;

    DirOrganization                 dirOrganization;

    ;

 

    /* Marks the beginning of a transaction.

       Necessary to utilize the method numRefCustAccount() */

    ttsBegin;

    prospect.initValue();

 

   try

    {

       //prospect

        numberSeq              = NumberSeq::newGetNum(smmParameters::numRefBusRelAccount());

        prospect.BusRelAccount    = numberSeq.num();

       

        dirOrganization.initValue();

        dirOrganization.Name = "test";

        dirOrganization.insert();

       

        prospect.Party = dirOrganization.RecId;

 

        //DirParty

 

        /* Creates a new instance of the DirParty class from an address book entity

           that is represented by the prospect parameter. */

        dirParty = DirParty::constructFromCommon(prospect);

        dirParty.parmName("Test");

        dirParty.parmNameAlias("Test");

        dirPartyPostalAddressView.LocationName      ='HeadQuarters ';

        dirPartyPostalAddressView.City              ='São Paulo';

        dirPartyPostalAddressView.Street            ='4th Avenue';

        dirPartyPostalAddressView.StreetNumber      ='18';

        dirPartyPostalAddressView.CountryRegionId   ='BRA';

        dirPartyPostalAddressView.State             ='SP';

       

        // Fill address

        dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);

        dirPartyContactInfo.LocationName    ='SouthStreet Contact Phone';

        dirPartyContactInfo.Locator         ='551291165341';

        dirPartyContactInfo.Type            = LogisticsElectronicAddressMethodType::Phone;

        dirPartyContactInfo.IsPrimary       = NoYes::Yes;

 

        // Fill Contacts

        dirParty.createOrUpdateContactInfo(dirPartyContactInfo);

        // Marks the end of transaction.

        prospect.insert();

        info(strFmt('Created prospect %1',prospect.BusRelAccount));

 

        ttsCommit;

    }

    catch(Exception::Error)

    {

       ttsAbort;

    }

}


Viewing all articles
Browse latest Browse all 175888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>