Dynamics AX Blog - Dynamics AX 4.0

These posts are machine-translated.
Currently, only posts are displayed, which are relevant for Dynamics AX version »Dynamics AX 4.0« Filter entfernen

RSS-Feed of this version

Search project names for a specific string

To list all (shared-) pojects that carry a specific text in the name, you can use the following code.

static void searchProjectName(Args _args)
    ProjectNode projectNode;


    projectNode    = infolog.projectRootNode();
    projectNode    = projectNode.AOTfindChild(#expProjectShared);
    projectNode    = projectNode.AOTfirstChild();


        if(strScan(projectNode.name(), "BR_", 0, 60))

        projectNode    = projectNode.AOTnextSibling();


Use a specific dimension as a dialogfield

If you want to use a particular dimension as a dialog field in Dynamics AX 2009 (or earlier versions), you can create your own Extended Data Type (derived from Criterias) as described below. The decisive factors are the relations of this EDT.

In the example, the cost center is to be offered as a dialog field.

Screenshot EDT

The example code was taken from a class which extends runBase.


Add object nodes to a shared project through code

Find below a short example, how to add object nodes to a shared project through code.

static void AddNodeToSharedProject(Args _args)
    projectNode projectNode;
    TreeNode treeNode;

    projectNode    = infolog.projectRootNode();
    projectNode    = projectNode.AOTfindChild(#expProjectShared);
    projectNode    = projectNode.AOTfindChild('MyProject');
    // Add objects
    treenode = TreeNode::findNode(#TablesPath+'\\'+tableid2name(tablenum(CustGroup)));

    treenode = TreeNode::findNode(#TablesPath+'\\'+tableid2name(tablenum(VendGroup)));
    treenode = TreeNode::findNode(#ClassesPath+'\\'+classStr(PriceDisc));

The so modified Project will look like this:



Loop through values of a Base enum

SysDictEnum SysDictEnum = new SysDictEnum(enumNum(SalesStatus));
int i;

for (i=0;i<SysDictEnum.values();i++)


Use macro within a SELECT statement

The SELECT-Statement in the example lists only active BOM items (Table BOM) on (active using the fields FromDate and ToDate). If the second parameter of the macro is empty (zero date ()), so all BOM items are listed.

static void useMacroInSelectStatement(Args _args)
    bom bom;
    date emptyDate;
    // parameters: %1 = table instance, %2 date, %3 empty date value
        && ( %2 == dateNull() || (
            ((%1.FromDate <= %2) && (%1.ToDate >= %2)) ||
            ((%1.FromDate == %3) && (%1.ToDate == %3)) ||
            ((%1.FromDate <= %2) && (%1.ToDate == %3)) ||
            ((%1.FromDate == %3) && (%1.ToDate >= %2))
    while select bom
    where bom.ItemId == '123'
    #bomDateFilter(bom, systemDateGet(), emptyDate)


Which fields are shown in an auto-generated lookup?

I was asked this question recently and was not able to answer.

But i still knew that i had seen a page where this is explained in detail. But i knew neither find it manually nor using various search engines.

But in old documents of mine i found the source then, the trick to find it using search engines, is using the old name of Microsoft Dynamics AX - Axapta to look for it!

Do this, you will quickly find following page:



How to create a AX<Table>-Class

If you need a so called AX<Table>-class can use the class AxGenerateAxBCClass.

Simply call this class in the AOT by right clicking and follow the wizard.

A that way generated class must be modified sometimes, but using the wizard is much faster than creating the class manually.

If the table changes, for example when adding new fields, you simply call that AxGenerateAxBCClass again and the AX<Table>-class will be extended accordingly.

How to use such AX<Table>-classes, i've described here.

Pages 1 2 » 


Posts of the actual month
Juli 2020
© 2006-2020 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.