Skip to main content

Posts

Showing posts with the label tablenum

Advance query filter in Ax 2012

As you know like wildcard operator to filter bunch of record in Axapta grid. In Ax 2012 you can use like wild card operator with query build range object also. QueryBuildRange QBR; QBR =SysQuery::findOrCreateRange(DS.dataSourceTable(tablenum(custtable)),fieldNum(Custtable,AccountNum)); QBR.value(SysQuery::valueLikeAfter(testTxt.text())); In above example we used value like after same way you can use valuelike also. Other you can use like SysQuery::valueUnlimited if there is no value for range purpose.

Get Primary key field name of table in MSD axapta by code

To Get Primary key field name of table in axapta by code you can try following code. First you need to declare variable for dictTable . DictTable _dictTable; DictField _dictField; ; _dictTable = new SysDictTable(tableNum(SalesTable)); // Then you need to call primary key field by passing table id like here we have pass salestable and dicttable.id() method will get id of salestable. _dictField = new SysDictField(dictTable.id(), dictTable.primaryKeyField()); info(dictField.name());

Code to show Dynamic Reports in MSD axapta

Code to show Dynamic Reports Write following code on init method of report in axapta ReportSection reportSection; DictTable dictTable; DictField dictField; Counter fieldCounter; super(); reportSection = element.design().autoDesignSpecs().addSection(ReportBlockType::Body); reportSection.table(tableNum(custTable)); dictTable = new DictTable(tableNum(custTable)); while (fieldCounter < 10) { fieldCounter++; dictField = new DictField(dictTable.id(), dictTable.fieldCnt2Id(fieldCounter)); reportSection.addControl(dictTable.id(), dictTable.fieldCnt2Id(fieldCounter)); }

Use of query elements in report using axapta

public boolean fetch() { QueryRun qr; QueryBuildRange rangeTransDate; Boolean ret; qr = new QueryRun(element); rangeTransDate = element.query().dataSourceTable(tablenum(CustTrans)).addRange(fieldnum(CustTrans, transDate)); rangeTransDate.value(queryRange(systemdateGet()-daysBack, systemDateGet())); rangeTransDate.status(RangeStatus::LOCKED); element.design().caption(strfmt("%1, %2", element.design().caption(), rangeTransDate.value())); if (qr.prompt() && element.prompt()) { while (qr.next()) { custTable = qr.get(tableNum(CustTable)); custTrans = qr.get(tableNum(CustTrans)); if (!custTable) { ret = false; break; } if (qr.changed(tableNum(custTable))) { element.send(custTable, 1); } if (qr.changed(tableNum(custTrans))) { element.send(custTrans, 2); } } ret = true; } else ret = false; return ret; }

How to build query object in axapta

Query query; QueryBuildDataSource qbds1; QueryBuildDataSource qbds2; QueryBuildRange qbr1; QueryBuildRange qbr2; QueryRun queryRun; CustTable custTable; ; query = new Query(); qbds1 = query.addDataSource(tablenum(CustTable)); qbds1.addSortField( fieldnum(CustTable, Name), SortOrder::Ascending); qbr1 = qbds1.addRange(fieldnum(CustTable,Blocked)); qbr1.value(queryvalue(CustVendorBlocked::No)); qbr2 = qbds1.addRange(fieldnum(CustTable,CustGroup)); qbr2.value(queryvalue('10')); qbds2 = qbds1.addDataSource(tablenum(SalesTable)); qbds2.relations(false); qbds2.joinMode(JoinMode::ExistsJoin); qbds2.addLink( fieldnum(CustTable,AccountNum), fieldnum(SalesTable,CustAccount)); queryRun = new QueryRun(query); while (queryRun.next()) { custTable = queryRun.get(tablenum(CustTable)); info(strfmt( "%1 - %2", custTable.Name, custTable.AccountNum)); } }