Skip to main content

Create new legal entity in ax 2012 through code

I came across a scenario to create new legal entity in ax2012 through code, and wrote down following job to create legal entities.

static void createLegalEntities(Args _args)
{
    CompanyInfo                         legalEntity;
    DirPartyPostalAddressView           partyPostalAddressView;
    int                                 coCount;
    int                                 gap;
    int                                 incrementOne = 1;

    for (coCount = 0; coCount <100; coCount++)
    {
        legalEntity.clear();
        partyPostalAddressView.clear();

        ttsBegin;

        legalEntity.Name = "X"+int2str(coCount);
        legalEntity.DataArea = "X"+int2str(coCount);
        legalEntity.insert();

        partyPostalAddressView.Party = legalEntity.RecId;
        partyPostalAddressView.CountryRegionId  = "USA";
        partyPostalAddressView.LocationName = "Office";
        DirPartyLocationEntity::createAddressForParty(partyPostalAddressView,conNull());

        ttsCommit;

        info ("legal entity: "+"X"+int2str(coCount)+" created");

    }
}

Comments

Popular posts from this blog

Get Position and Department of an employee | AX 2012

A simple job to get position/designation and department of an employee using employee id: static void WorkerPositionDepartment(Args _args) {     HcmWorker                       hcmWorker;     HcmPositionWorkerAssignment     hcmPositionWorkerAssignment;     OMOperatingUnit                 oMOperatingUnit;     HcmPositionDetail               hcmPositionDetail;     HcmJob                          hcmJob;     HcmPosition             ...

Run SSRS report using x++ code | AX 2012

This post describes how to run an SSRS report through x++ code and passing report parameters as well. Its a simple code and comments are added for further ease in code understanding! public static void runSSRSReport() {     SrsReportRunController controller;             controller = new SrsReportRunController();     controller.parmLoadFromSysLastValue(false);      // write report name and its design in quotes that you want to run     controller.parmReportName("ReportName.DesignName");      // set additional, optional properties like setting landscape to true     controller.parmReportContract().parmPrintSettings().landscape(true);          // set print destination screen/printer/file etc.     controller.parmReportContract().parmPrintSettings().printMediumType (SRSPrintMediumType::S...

How to pass value from form to class, AX 2012

Courtesy : DUG Dynamics User Group It's very simple to pass value from a form to a class by defining a method on form and using args.caller() in the class. 1. Take a String control in the form design like  string Customer Name. 2. Go to String control properties and set "Auto declaration" property to "Yes". 3. Go to form methods -> new method -> write return type method like;           public str customerName()      {            return CustomerName.Text();      } 4. Go to main() method of the class and type following:     public static void main(Args args)     {            str custName;            ;                if(formHasMethod(a...