Sales order - DictField object not initialised

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

Error
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)\Classes\FormRun\task
(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:
\Classes\SysQueryBuilder\buildRelation
Add variable declaration:
int             k, relLines;

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

With this code:
k       = 1;
relLines= dictRelation.lines();
do
{
    dictField   = _orgDictTable.fieldObject(dictRelation.lineExternTableValue(k));
    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);
    
    qr.prompt();
    
    qbds = qr.query().dataSourceTable(tableNum(SalesTable));
    
    while (qr.next())
    {
        salesTable = qr.get(tableNum(SalesTable));
    }
}
Problematic relation is for example with table PrintMgmtDocInstance (Print management document instance)

 

Search

About

DaxOnline.org 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 and "buy me a coffee" link.
Join us.

Blog Tags