Kristers Homičs
Kristers Homičs

Reputation: 57

Is there a way to work with records that you marked in table on X++?

I want to work with table records that is selected (Marked), Example - I have 10 records in table and i mark 5 of them. Expected - when i work with selected records, it should look only on that 5 records, not whole 10.

So far i have this code that selects all records:

while select Table
                where table.JournalId == table.JournalId

Is there a way to make it select only marked records, not everything? That select is writen in class. I need to get those marked records into that class where that select is writen...

Upvotes: 2

Views: 3940

Answers (1)

rjv
rjv

Reputation: 1090

You need to pass the formdatasource object into the class that is selecting the records, and then use the MultiSelectionHelper to loop through the selected records on the formdatasource.

In the example below, the object salesTableFormDataSource needs to be passed in from the form to the class you are using. Obviously replace that with whatever your datasource/table needs are.

MultiSelectionHelper selection = MultiSelectionHelper::construct();
selection.parmDatasource(salesTableFormDataSource);
SalesTable salesTable = selection.getFirst();

while (salesTable)
{
    //do something with your table buffer.
    salesTable = selection.getNext();
}

Upvotes: 4

Related Questions