Skip to main content

Posts

Showing posts with the label querybuildrange

Get Product based on Item group in MSD Ax 2012

To get Item details or  Product based on Item group in Ax 2012 you can try below code in job. In this job Test_InventItemGroup is query on which you need to include inventItemgroupItem and inventTable. I have pass the range TT as item group same way you can use in your customization. Query query; QueryRun qr; QueryBuildDataSource qbds; QueryBuildRange queryBuildRange; InventItemGroupItem IntventTest,InventTest1; ; query = new Query(queryStr(Test_InventItemGroup)); qbds = query.dataSourceTable(tableNum(InventItemGroupItem)); queryBuildRange = qbds.addRange(fieldNum(InventItemGroupItem,ItemGroupId)); queryBuildRange.value("TT"); qr = new QueryRun(query); while(qr.next()) { IntventTest= qr.get(tableNum(InventItemGroupItem)); select ItemId from IntventTest1 where IntventTest1.ItemGroupId == IntventTest.ItemGroupId; info(strFmt("%1",IntventTest.ItemId)); }

Add tables to query build datasource in MSDAX

Add tables to query build datasource ,addlink,relation static void QBDSExample(Args _args) { Query query; QueryBuildDatasource datasource; ; query = new Query(); // Add purchtable main datasource datasource = query.addDataSource(tableNum(purchtable)); // Add child datasource "purchline" datasource = datasource.addDataSource(tableNum(purchline)); // Set the join mode datasource.joinMode(JoinMode::InnerJoin); datasource.relations(false); datasource.addLink(fieldNum(purchtable, purchid), fieldNum(purchline, purchid)); info(query.xml()); }

System Classes Ranges using MSD axapta

System Classes Ranges using MS axapta SysQuery query; SysQueryRun queryRun; QueryBuildDataSource custInvoiceJourDS; QueryBuildRange rangeInvoiceAccount, rangeInvoiceDate, rangeDimensionDepartment; ; query = new Query(); custInvoiceJourDS = query.addDataSource(tablenum(CustInvoiceJour)); rangeInvoiceAccount = custInvoiceJourDS.addRange(fieldnum(CustInvoiceJour, InvoiceAccount)); rangeInvoiceAccount.value(queryValue("5000")); rangeInvoiceDate = custInvoiceJourDS.addRange(fieldnum(CustInvoiceJour, InvoiceDate)); rangeInvoiceDate.value(queryRange(datenull(), systemdateget())); rangeDimensionDepartment = custInvoiceJourDS.addRange(fieldId2Ext( fieldnum(CustInvoiceJour, Dimension), 1)); rangeDimensionDepartment.value(queryValue("Sales")); queryRun = new SysQueryRun(query); queryRun.prompt();

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)); } }