Add a sum field in form


   I just Created a form which shows customer Invoice related data i just also filter of two field (fromdate,toDate)

 when i filter the form it and click on a button it should display sum of Invoice Amount of all the current records

 in a grid so what i need to do pls advice to me for that i also sharing the screen shot of my form.

Version AX2012R3


  • Hi Taukeer ,

    You can use sum(aggregate function) for that invoice amount field.
  • try this:

    void clicked()
    Query query = new Query(Salesline_ds.queryRun().query());

    QueryBuildDataSource qbds = query.dataSourceTable(tableNum(SalesLine));
    QueryRun qr;
    SalesLine salesLineLocal;
    date fromDate = systemDateGet();
    date toDate = (systemDateGet() + 100);

    qbds.addGroupByField(fieldNum(SalesLine, DateField));
    qbds.addSelectionField(fieldNum(SalesLine, SalesPrice), SelectionField::Sum);
    qbds.addRange(fieldnum(SalesLine,DateField)).value(queryRange(fromDate, toDate));

    qr = new QueryRun(query);;
    salesLineLocal = qr.get(tableNum(SalesLine));



  • In reply to Kunal:

    Here is the complete blog post: Summarized values in AX form.