Order Items/Dimension per Customer Account

Hi,

I have a report with four datasource. The report fetch records based on the first datasource and in the fetch method, it gets the current row(queryRun_Current.get(MyTable)) of the remaining three datasource. There are existing fields in my sort fields and added a line in init method of datasource - this.query().dataSourceNo(3).addOrderByField(fieldnum(myTable, myField),sortOrder::Ascending);. I need to sort the items based on itemid and inventdimid but the things that I made fails. Need your help guys. Thanks in advance.

Do you have a query for this report? If so why cannot you add the sorting at query level?

There is a query only on the first datasource. So, in the while loop of the first datasource, it extracts the current rows of the remaining datasources.

Not sure what do you mean by that? May be you can explain with an example.

    while (queryRun_Current.next())	//loop on the first datasource
    {
        StandardTable1_Current        = queryRun_Current.get(tablenum(StandardTable1));
        StandardTable2_Current        = queryRun_Current.get(tablenum(StandardTable2));
        StandardTable3_Current        = queryRun_Current.get(tablenum(StandardTable3));

        //my calculation logic goes here 
    }

In the code above, there I have a loop on the first database, and it gets the current record/row per datasource. So, is there’s a way that I can sort the other datasources during every iteration? So when it iterates, it will automatically sort all the datasources.

You have to apply sorting while building the query or before running it, but not while running it.

I already did. But it seems not working. I put my code in the init method of my datasource.

this.query().dataSourceName('StandardTable3').addOrderByField(fieldNum(StandardTable3, ItemId), sortorder::Ascending);
this.query().dataSourceName('StandardTable3').addOrderByField(fieldNum(StandardTable3, InventDimId), sortorder::Ascending);

Can you tell about your query? how did you built it?
Try avoiding hard coding the data source names. this.query().dataSourceTable(tablenum(StandardTable3))
have you tried by having them in fetch method?

Here is my fetch method;

while (queryRun_Current.next()) //loop on the first datasource
{
StandardTable1_Current = queryRun_Current.get(tablenum(StandardTable1));
StandardTable2_Current = queryRun_Current.get(tablenum(StandardTable2));
StandardTable3_Current = queryRun_Current.get(tablenum(StandardTable3));

//my calculation logic goes here
}

You haven’t said anything about your query?

As a resolution, I dump the data being extracted my query on a temporary table and make use of while select statement order by in my fetch method.