Sales order - DictField object not initialised

Editing query and getting error when trying to display datasources to join to Sales orders?

DictField object not initialised.

Stack trace
(C)\Classes\SysQueryBuilder\buildRelation - line 67
(C)\Classes\SysQueryBuilder\buildPopupMenuItem - line 49
(C)\Classes\SysQueryBuilder\buildPopupMenu - line 46
(C)\Classes\SysQueryBuilder\buildContext - line 12
(C)\Classes\SysQueryForm\dataSourceEdit - line 40
(C)\Forms\SysQueryForm\Designs\DesignList\DataSourceTree\Methods\context - line 14
(C)\Forms\SysQueryForm\Methods\task - line 31
(C)\Classes\SysSetupFormRun\task - line 20

It is a bug in standard AX application. There is a fix:
Edit following method:
Add variable declaration:
int             k, relLines;

Replace following line:
dictField   = _orgDictTable.fieldObject(dictRelation.lineExternTableValue(1));

With this code:
k       = 1;
relLines= dictRelation.lines();
    dictField   = _orgDictTable.fieldObject(dictRelation.lineExternTableValue(k));
while (!dictField && k <= dictRelation.lines());
You can test result using following job:
static void testSysQueryBuilder(Args _args)
    Query                   q   = new Query(queryStr(SalesTableSelect));
    QueryRun                qr;
    SalesTable              salesTable;
    QueryBuildDataSource    qbds;
    qr  = new QueryRun(q);
    qbds = qr.query().dataSourceTable(tableNum(SalesTable));
    while (
        salesTable = qr.get(tableNum(SalesTable));
Problematic relation is for example with table PrintMgmtDocInstance (Print management document instance)


About is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags