Error executing code: QueryBuildDataSource object not initialized. in ax 2012

protected void prePromptModifyContract()

{

mmgrpmain _mmgrpmain;

Query qry = this.getFirstQuery();

QueryBuildDataSource qbds;

QueryBuildRange qbrRequestID;

qry = new Query();

_mmgrpmain = args.record();

qry.dataSourceTable(tableNum(mmgrpmain)).clearRanges();

qbrRequestID = qry.dataSourceTable(tableNum(mmgrpmain)).addRange(fieldNum(mmgrpmain,id));

if (_mmgrpmain)

{

qbrRequestID.value(strFmt("%1",_mmgrpmain.id));

}

when i click report button error throing…pls help me.

Error executing code: QueryBuildDataSource object not initialized.

Stack trace

(C)\Classes\QueryBuildDataSource\clearRanges

(C)\Classes\mmgrpcontroller\prePromptModifyContract - line 18

(C)\Classes\SrsReportRunController\startOperation - line 7

(C)\Classes\mmgrpcontroller\main - line 9

}

Would it be that difficult to tell us which line of code is failing?

If you actually debug your code (which should be the very first thing to do), you’ll likely find that qry.dataSourceTable(tableNum(mmgrpmain)) doesn’t return anything. It must mean that the query doesn’t contain the table.

Hi Muhammad,

Wrong syntax for “tableNum(mmgrpmain)”.

ok thanks what is syntax mr. Dang Hoang Thuyen