Dear Experts
I have different columns in grid for Amount I want total at bottom of grid and grid is bound to custom table (ARM_INVOICEDETAIL) and their is no query in AOT how can i take sum of each column.
Thanks
Afridi
I found Below query on Martin Page
// Copy the query
Query query = new Query(SalesLine_ds.queryRun().query());
QueryBuildDataSource qbds = query.dataSourceTable(tableNum(SalesLine));
QueryRun qr;
Salesline summedTrans;
// Sum LineAmountMst
qbds.addSelectionField(fieldNum(SalesLine, LineAmount), SelectionField::Sum);
qr = new QueryRun(query);
// Run the query
qr.next();
// Get the data
summedTrans = qr.get(tableNum(SalesLine));
// Set the new sum to the control
RealEdit.realValue(summedTrans.LineAmount);
txtitemid.text("1000");
*This post is locked for comments
Thanks Martin I Used your code and it is working
Can you explain what kind of problem you have with the code you've posted?
Also, the code uses a query from the form, not some separate query in AOT. If your form has a datasource, it also has a query.
In the table ARM_INVOICEDETAIL , create a new display method Sum() and add the fields which you need.
like this.Field1 + this.Field2 .. etc and use the display field at the end of the row of the grid
If you want to sum only one field out of the table, use the same procedure above and write a simple query
Select Sum(LineAmount) from SalesLine
where Salesline.SalesId = this.SalesID
and return SalesLine.LineAmount ..This should give you the whole value
Hi
One way is to create a query object in AOT, with the desired sum fields. use that query in your code to get the result.
for eg: for SalesLine, in the query >> Datasources >> SalesLine >> fields >> New Sum.
select the field as LineAmount.. you must have the Dynamic property to "No" before you do this.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156