What is wrong in this code?

I wrote code below into HRMLoanTable, I run this in a webform but when the user clicks the sort buttons above the webgrid the following error occurs. When I use this code in a normal form sorting works correctly. What may be the error? Error Message: "AxaptaCOMConnector.Axapta.1 error ‘80042041’ Error executing code: QueryBuildDataSource object not initialized. Stack trace: \Classes\QueryBuildDataSource\sortFieldCount \Classes\WebFormHtml\sort - line 20 \Classes\WebFormHtml\handleButtons - line 54 \Classes\WebFormHtml\parseArgs - line 41 \Classes\WebSession\processAxaptaForm - line 22 \Classes\WebAppEngineWebLet\run - line 20 \Classes\WebLet\runCache - line 70 \Classes\WebAppWebLet\runCache - line 4 \Classes\WebPage\runCompiled - line 59 \Classes\WebPage\run - line 3 \Classes\WebApplication\Show - line 33 " The code I wrote is, public void init() { Query query; QueryBuildDataSource queryBuildDataSource ; QueryBuildDataSource queryBuildDataSource1; QueryBuildDataSource queryBuildDataSource2; QueryBuildRange queryBuildRange; QueryBuildRange queryBuildRange1; ; query = new query(); queryBuildDataSource = query.addDataSource(tablenum(HRMLoanTable)); queryBuildRange1 = queryBuildDataSource.addRange(fieldNum(HRMLoanTable, description)); queryBuildDataSource1 = queryBuildDataSource.addDataSource(tablenum(HRMVirtualNetworkLoan)); queryBuildRange = queryBuildDataSource1.addRange(fieldnum(HRMVirtualNetworkLoan, endDate)); queryBuildRange.value(sysquery::valueEmptyString()); queryBuildDataSource1.addLink(fieldnum(HRMLoanTable, hrmLoanId), fieldnum(HRMVirtualNetworkLoan, hrmLoanId)); queryBuildDataSource1.joinMode(JoinMode::NoExistsJoin); this.query(query); super(); }

You should use your objects(QBR,…) after super()

I think simply putting this.query(query); after super() will do the job.


I have a same problem with the error query build datasource object not initialized.

I want to get data from the range in query, because I want to use that data in select statement.

My code is:

boolean ret;
Qty qty;
QueryBuildDataSource qbds, queryBuildDataSource;
QueryBuildRange qbr;
QueryBuildRange queryBuildRange;

str a;


ret = super();
query = new Query();
queryRun = new QueryRun(query);

qbr = qbds.addRange(fieldNum(custPackingSlipJour, NOV_ContainerID)); <.-- here is an error!!!
a = qbr.value();

select statement…