Friday, February 26, 2021

Send selected records from Temp Form Datasource to Class

 Recently, I had the need to send selected records of Form datasource that is a Temp table. 

The initial searches led me to the MultiSelectionHelper class with code something like this in my class:

MultiSelectionHelper helper = MultiSelectionHelper::construct();
helper.parmDataSource(_args.record().dataSource());

myTempTable = helper.getFirst();

while (myTempTable.RecId != 0)
{
    ... [LOGIC] ...
    myTempTable = helper.getNext();
}

This did NOT work at all.  I tried every type of table; Temp, InMemory, Regular.  I could not get MultiSelectionHelper to work.

So, I ended up using FormDataSource:

FormDataSource fds;
fds = _args.record().dataSource();

myTempTable = fds.getFirst(true);

while (myTempTable.RecId != 0)
{
    ... [LOGIC] ...
    myTempTable = fds.getNext();
}

Very similar code.  Just be sure to put 'true' in your call to 'getFirst' on the FDS object as that will ONLY retrieve marked / selected records.

No comments:

Post a Comment