Data import export in ax 2012. When we need to add few new fields to the exported document that exist in source table.

1. Add fields to the source table

2. Add fields to the entities tmp table

3. Create new processing group DAT/Data import export framework/Common/processing group/new

4. open entities and generate mapping

5. modify source mapping

6. Ensure target mapping is correct

– View target mapping

–  if incorrect

– DAT/Data import export framework/Common/Setup/Target entities, choose correct entity

– modify target mapping

– refresh diagram

– switch to mapping details

– Generate mapping 9 from scratch)

– update mapping if required

– save

7. (tiny button after entities button)From processing group get staging data

8. copy data to target

9. check if everything worked successfully
Tips: – when testing file, before import of staging data to the staging table ensure that the file that you’re working with, is closed.


How to order form grid by field that is not included in the data source

So this can be done by updating a query method init of the data source on which grid is based:


 QueryBuildDataSource qbds;
 QueryBuildDataSource qbds2;
 QueryBuildDataSource qbdsn;

//original data source
qbds = DataSource_ds.query().dataSourceTable(tableNum(DataSourceTable));

 qbds2 = qbds.addDataSource(tableNum(OtherTable));
 qbdsn = qbdsn-1.addDataSource(tableNum(OtherTableN));
 qbdsn.addSortField(fieldNum(OtherTableN, FieldYouWantToSortOn));

Manually order record in the form grid

You know those kind of forms where you can use buttons to order records in the right position?

It is quite easy to replicate. It won’t work for all solutions though,

Example of the standard code is a WHSLocDirTable form.

To implement this solution you would have to make changes to the source table ( Add additional field, index, field group , methods for update , insert and delete, as well as moving logic,)

add changes to the the form ( additional field, buttons for up and down and related code, as well as make changes to init method of the form ( to sort by position) and some changes that will have to be implemented on the data source. )



Delete connection between not existing worker and existing user

Which stops you from assigning worker to the user ( this happens usually after migrations of data or something similar)


static void DelConBetweenNotExistWorkerandUser(Args _args)
    DirPersonUser         dirPersonUser;
    UserInfo                   userInfo;
    int                             counter;
    while select forUpdate dirPersonUser notExists join UserInfo
        where DirPersonUser.User ==
        info ( DirPerson::find(dirPersonUser.PersonParty).Name);


How to check weather all customers have nameAlias defined

I think one of the easier methods would be to run  this job, which will show number of all customers, and customer with Name Alias defined.

static void AmountOfCustomersWithNAmeAlias(Args _args)
    CustTable custtable;
    int counter1, counter2;

    while select CustTable
        if (CustTable.nameAlias())
   info (strFmt(“Counter1 %1, counter2 %2”,counter1, counter2));

Check with Regexp if company name follows certain pattern

In my case I was looking for 2 U letters anywhere in the name or the short name of the company.

static void Job107(Args _args)
    TextBuffer companyShort = new TextBuffer();
    TextBuffer companyName = new TextBuffer();

    if (companyName.find(‘u.*u’) ||companyShort.find(‘u.*u’))

Nice links to check regexp stuff : 

And online editor to check if you were right:

unable to connect to the microsoft visual studio remote debugging monitor

When debugging on server do not forget to check if the Visual Studio Remote Debugging Monitor   was run.

If not find it here:

Program Files\Microsoft Visual Studio 1x.0\Common7\IDE\Remote Debugger\x86\msvsmon.exe

Program Files\Microsoft Visual Studio 1x.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe

and run it as administrator

Happy debugging

generating method (with specific code) from X++ code

So the issue was that I was supposed to create bunch of methods ( like parm) , when I knew the table fields, and where they had really similar code.

Instead doing that manually I have created a following job. Hope it helps 🙂

static void aka_createDetermineMethods(Args _args)
     TreeNode tnclass, tntable,tnfield;
     MemberFunction tnMethod;
     str name;
     str code = "protected %1 %2()\n"+
                "//overwritten in sub classes\n"+
                " return '%3';\n"+

     tnClass = TreeNode::findNode(@"\Classes\[class to add methods]");
     tntable = TreeNode::findNode(@"\Data Dictionary\Tables\CustTable\Fields");
     tnfield = tntable.AOTfirstChild();

    while (tnfield)
         name = "parm"+tnfield.treeNodeName();
         tnMethod = tnClass.AOTfindChild(name);
        if (!tnMethod)
            tnMethod = tnClass.AOTadd(name);
        tnMethod.AOTsetSource(strFmt(code, tnfield.AOTgetProperty("ExtendedDataType"), name,name));
        tnfield = tnfield.AOTnextSibling();

Debugging on server is impossible, but yet is required

If you have faced the similar situation using Microsoft Dynamics AX, do not worry as there are few solutions that may help you. Sometimes there are even less time consuming than the debugging in server itself.

One of the most favourite ones is to enter all data in the file, and than be able to trace necessary data. you Can find example below

 AsciiIo file;
 FileName fileName;
 FileIoPermission perm;
 container conTextLine;

 fileName = @"\\c:\temp\sometext.txt";

perm = new FileIoPermission(fileName, 'W');


file = new AsciiIo(fileName, 'W');

//super smart code that needs debuggin
 file.writeRaw("Super  secret value to export");
//some other code

 file = null;