Nico
Nico

Reputation: 1197

Iterate through selected grid data and get field values of n-th datasource

I want to loop through the selected lines on a grid and get the field-data of each line, which is from a second/third datasource linked to the first datasource via inner join.

Looping through selected lines and get data of first DS is quite easy, like

x = myDS_getFirst();
while (x)
{
    doSth();
    x = myDS.getNext();
}

When using something like

x = mySecondDS_getFirst();
while (x)
{
    doSth();
    x = mySecondDS.getNext();
}

I always get only the last selected line. Is there a simple way to access the n-th datasource of selected line without doing a select from.... in each iteration? The data is already displayed in the grid...

What I tried:

but issue stays the same.

In AX2012 it works fine, but not in AX2009. Is this a known issue in 2009? How to achieve this?

Upvotes: 0

Views: 4088

Answers (1)

10p
10p

Reputation: 6706

Try using joinChild, e.g.

SalesTable t;
SalesLine l;

for (t = SalesTable_ds.getFirst(true) ? SalesTable_ds.getFirst(true) : SalesTable_ds.cursor(); t; t = SalesTable_ds.getNext())
{
    l = t.joinChild();
    info(strFmt("%1 - %2", t.SalesId, l.LineNum));
}

Upvotes: 1

Related Questions