In a form's dataSource executeQuery method :
QueryBuildDataSource qbsInventTrans;
QueryBuildRange qbrItemId;
// Go get the current dataSource you're in (InventTrans)
qbsInventTrans = this.query().datasourceTable(tableNum(InventTrans));
// Set this dataSource in "group by" so that the data of this table shown in
// a grid will be grouped.
qbsInventTrans.orderMode(OrderMode::GroupBy);
// Fields you want to be grouped by.
qbsInventTrans.addSortField(fieldNum(InventTrans, TransType));
qbsInventTrans.addSortField(fieldNum(InventTrans, TransRefId));
qbsInventTrans.addSortField(fieldNum(InventTrans, CustVendAC));
qbsInventTrans.addSortField(fieldNum(InventTrans, DateExpected));
qbsInventTrans.addSortField(fieldNum(InventTrans, ItemId));
// Add a range on ItemId to limit for a specific Item, "11444".
qbrItemId = qbsInventTrans.addRange(fieldNum(InventTrans, ItemId));
qbrItemId.value("11444");
Here it uses "addLink" to add a DataSource (InventTrans) to the already existing query "SalesLine" :
QueryBuildDataSource qbdsInventTrans;
QueryRun query = new QueryRun(queryStr(SalesLine));
SalesLine salesLine;
InventTrans invTrans;
query.query().dataSourceTable(tableNum(SalesLine)).rangeField(fieldNum(SalesLine, salesId)).value(queryValue(salesTable.salesId));
qbdsInventTrans = query.query().dataSourceTable(tableNum(SalesLine)).addDataSource(tableNum(InventTrans));
qbdsInventTrans.addLink(fieldNum(SalesLine, InventTransId), fieldNum(InventTrans, InventTransId));
Next method example :
Using the above query object "query" I can browse that query doing this :
Query.reset(); //Just to make sure it's positioned at the beginning
Query.setRecord(invTrans);
Query.setRecord(salesLine);
While (Query.next()) { //Browse every record of the query.
Info(invTrans.someField); //Show field "someField" of InventTrans;
Info(salesLine.someField); //Show field "someField" of salesLine;
}
Query object is a definition of the structure of your query just like the query in the AOT->Queries. QueryRun is an "executable" form of your query. It help you browse thru the query structure and select record. I don't build Query with code, I prefer to build it in the AOT and use it doing :
QueryRun query = new QueryRun(queryStr(myAOTQuery));
But if you need to build query dynamically you'll have to work with Query object.
I don't know what element.query() do in a form.
I've tried to explain it the best I can but I think it still looks confusing. So just ask more precise questions and we'll help you out.
Welcome to the Axapta world! And welcome to the forum too.
Steeve...
-----Message d'origine-----
De�: axapta_dude [mailto:[EMAIL PROTECTED]
Envoy�: 2 juin 2004 13:45
��: [EMAIL PROTECTED]
Objet�: [development-axapta] help on query
hi...i need some simple and plain explanation/example in using query on form using class
mention below.I'm new in axapta developement and help file in axapta is a bit confusing
for me:
1.Query
2.QueryBuildDatasource
3.QueryBuildRange
4.QueryRun
-how to retrieve data using next method
-explanation for addlink and simple example
-explanation/purpose for element.query()
I really hope you guys can help me.
Thanx in advanced
Yahoo! Groups Links
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/development-axapta/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

