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

3.7k views Asked by At

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:

  • pseudo-Code example above
  • accessing n-th ds in while-loop
  • using the MultiSelectionHelper
  • changing the joins on datasources from inner to active/passive/delayed

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?

1

There are 1 answers

0
10p On

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));
}