Create customer through X++

Class runner — Finance and Operations (dynamics.com)

Second, change ‘&mi=DefaultDashboard’ and replace it with ‘&mi=SysClassRunner‘. This tells the system to run a class.

Third, add the following text to the end of the URL: ‘&cls=<TheNameOfYourClass>‘. Replace <TheNameOfYourClass> with the name of your class. In the example above, it would be TestRunnableClass.

The final format of your URL should be:

https://<URL of your D365 environment>/?cmp=<YourCompany>&mi=SysClassRunner&cls=<TheNameOfYourClass>

https://rsmta-peter1234567aos.cloudax.dynamics.com/?mi=SysClassRunner&cls=TestRunnableClass

Finally, copy this URL into your browser, and hit enter. The browser will then run the D365 runnable class (job). You will see the message ‘Class ‘<TheNameOfYourClass>’ completed’ once your job has finished running.

class GD_RunIntegration

{

   /// <summary>

/// Runs the class with the specified arguments.

/// </summary>

/// <param name = “_args”>The specified arguments.</param>

publicstaticvoid main(Args _args)

   {

SamCustomServiceTest::JobCreateCustomer();

   }

}

class SamCustomServiceTest{    static void JobCreateCustomer ()    {        CustTable                    custTable;       NumberSeq                    numberSeq;        Name                         name ='SouthSide Street GVND';         DirParty                        dirParty;        DirPartyPostalAddressView       dirPartyPostalAddressView;        DirPartyContactInfoView         dirPartyContactInfo;        ;         /* 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();  //CHI32';//            custTable.CustGroup     ='020';            custTable.Currency      ='BRL';            custTable.PaymTermId    ='10DD';            custTable.PaymMode      ='CHEQUE-01';             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      ='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.            ttsCommit;        }        catch(Exception::Error)        {            ttsAbort;           // throwException::Error;        }    }  }

Leave a comment