Dynamics AX Blog - Posts from April 2015

These posts are machine-translated.
Currently, only posts from »April 2015« are displayed Filter entfernen

List all modified objects from current layer

To browse the AOT for particular objects, you can use the TreeNode class. I've already posted some examples in the past.

In Dynamics AX 2012, a new option has been added, and although there are now some tables that begin with SysModel*. You can also use these tables to browse the AOT objects/properties.

An example of such a query is the following job, which returns (unsorted) all objects that have been modified in the current layer.


 
 
 

Create BOM through code

Using the following code you will be able to create a BOM through code.

static void createBomTableVersion(Args _args)
{
    AxBOMTable axBOMTable;
    AxBOMVersion axBOMVersion;
    AxBOM axBOM;
    InventTable inventTable = InventTable::find("100160");
    InventDim inventDim;

    try
    {
        ttsbegin;

        // BOM Table
        axBOMTable = AxBOMTable::construct();
        axBOMTable.validateInput(true);
        axBOMTable.continueOnError(false);
        axBomTable.parmBOMId(BOMTable::numberSeq().num());   
        axBOMTable.parmItemGroupId(inventTable.itemGroupId());
        axBOMTable.parmApprover(HcmWorker::userId2Worker(curUserId()));
        axBOMTable.parmApproved(NoYes::Yes);
        axBOMTable.parmName("Name of BOM");
        axBOMTable.parmSiteId("GF");

        axBOMTable.save();

        // BOM Version
        inventDim.clear();
        inventDim.InventSiteId = axBOMTable.parmSiteId();
        inventDim = InventDim::findOrCreate(inventDim);

        axBOMVersion = AxBOMVersion::construct();
        axBOMVersion.validateInput(true);
        axBOMVersion.continueOnError(false);
        axBOMVersion.parmBOMId(axBOMTable.parmBOMId());
        axBOMVersion.parmItemId(inventTable.ItemId);
        axBOMVersion.parmApprover(HcmWorker::userId2Worker(curUserId()));
        axBOMVersion.parmApproved(NoYes::Yes);
        axBOMVersion.parmActive(NoYes::Yes);
        axBOMVersion.parmInventDimId(inventDim.InventDimId);
        axBOMVersion.save();

        // BOM
        inventDim.clear();
        inventDim.InventSiteId = axBOMTable.parmSiteId();
        inventDim.ConfigId = "RoundNeck";
        inventDim.InventSizeId = "XS";
        inventDim.InventStyleId = "SlimFit";
        inventDim.InventColorId = "Blue";
        inventDim.InventLocationId = "902";
        inventDim = InventDim::findOrCreate(inventDim);

        axBOM = AxBOM::construct();
        axBOM.validateInput(true);
        axBOM.continueOnError(false);
        axBOM.parmBOMId(axBOMTable.parmBOMId());
        axBOM.parmItemId("100158");
        axBOM.parmInventDimId(inventDim.InventDimId);
        axBOM.parmBOMQty(17);
        axBOM.save();

        ttscommit;
    }
    catch
    {
        throw error("BOM creation failed");
    }
}

 
 
 

Congratulations on the Microsoft MVP Award 2015!

...was the subject of the e-mail which reached me yesterday and informed me that I was awarded for the Microsoft MVP Award.

I am very happy and only want to say: Thank you!


 
 
 

 

 
 
 
Posts of the actual month
April 2015
MoTuWeThFrSaSu
 12345
6789101112
13141516171819
20212223242526
27282930 
 
© 2006-2025 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.