Hello All!

I'm facing a little problem when trying to group and sum in a query object:

I have some parmLines for ex.:

ItemId        ReceiveNow

000001        4,00
000001        2,00
000001        3,00
000002        5,00

and I'm expecting:

000001        9,00
000002        5,00


in ordinary Sql that would be very simple, but i'm not able to do this on AX 
Query object.

I tried the following, but it's summing all the quantities regardless of Item 
ID.

public void init()
{

    QueryBuildDataSource  qbds;
    QueryBuildDataSource  qbds1;
    Query                 query;
    ;

    super();

    query = this.query();

    qbds = query.dataSourceName(this.name());


    
qbds.addSelectionField(fieldNum(purchParmLine,ItemId),SelectionField::Database);
    
qbds.addSelectionField(fieldNum(purchParmLine,ReceiveNow),SelectionField::Sum);

    qbds.orderMode(OrderMode::GroupBy);


}

Reply via email to