When i tried to get the select rows from the grid, just get the last selected
class SalesTableListPage_Form_ReleaseToWarehouseSecHandler
{
[FormControlEventHandler(formControlStr(SalesTableListPage, ReleaseToWarehouse), FormControlEventType::Clicked)]
public static void ReleaseToWarehouse_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun form = sender.formRun();
FormDataSource SalesTable_ds = form.dataSource() as FormDataSource;//(formDataSourceStr(SalesTableListPage, SalesTable)) as FormDataSource;
SalesTable salesTable ;
for(salesTable = SalesTable_ds.getfirst(true) ? SalesTable_ds.getfirst(true) : SalesTable_ds.cursor();
salesTable;salesTable = SalesTable_ds.getnext())
{
}
}
}
OR
[FormControlEventHandler(formControlStr(InventTransferOrders, ButtonInventTransferShip), FormControlEventType::Clicked)]
public static void ButtonInventTransferShip_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun element = sender.formRun();
FormDataSource SalesTable_DS = element.dataSource(formDataSourceStr(InventTransferOrders, inventTransferTable));
MultiSelectionHelper selectionHelper = MultiSelectionHelper::construct();//Create instance of class
Set selectedRecords = new Set(Types::Record);//Declare a set of type record
inventTransferTable inventTransferTable;
inventTransferTable =sender.formRun().dataSource(1).cursor();
selectionHelper.parmDataSource(SalesTable_DS); //Set the datasource
inventTransferTable = selectionHelper.getFirst(); //assign to table buffer the reference to selected record(s)
if (inventTransferTable.RecId)
{
while (inventTransferTable)
{
info(inventTransferTable.TransferId);
inventTransferTable = selectionHelper.getNext();
}
}
}
This code worked fine with other forms but salesorderlistpage just get one record
Thank you in advance.
Using MultiSelectionHelper is the recommended approach. Nevertheless your second code snippet is for a wrong for and a wrong table. Could you please fix that and test it again, and if it still doesn’t work, share your new code with us?
[FormControlEventHandler(formControlStr(SalesTableListPage, ReleaseToWarehouse), FormControlEventType::Clicked)]
public static void ReleaseToWarehouse_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun element = sender.formRun();
FormDataSource SalesTable_DS = element.dataSource(formDataSourceStr(SalesTableListPage, salesTable));
MultiSelectionHelper selectionHelper = MultiSelectionHelper::construct();//Create instance of class
Set selectedRecords = new Set(Types::Record);//Declare a set of type record
SalesTable salesTable;
salesTable =sender.formRun().dataSource(1).cursor();
selectionHelper.parmDataSource(SalesTable_DS); //Set the datasource
salesTable = selectionHelper.getFirst(); //assign to table buffer the reference to selected record(s)
if (salesTable.RecId)
{
while (salesTable)
{
info(salesTable.SalesId);
salesTable = selectionHelper.getNext();
}
}
}
salesTable = selectionHelper.getNext();
after first get ,get empty recId

Thanka Martin
First of all, let me simplify your code a bit:
[FormControlEventHandler(formControlStr(SalesTableListPage, ReleaseToWarehouse), FormControlEventType::Clicked)]
public static void releaseToWarehouse_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun element = sender.formRun();
FormDataSource salesTable_ds = element.dataSource(formDataSourceStr(SalesTableListPage, salesTable));
MultiSelectionHelper selectionHelper = MultiSelectionHelper::construct();//Create instance of class
selectionHelper.parmDataSource(SalesTable_DS); // Set the datasource
SalesTable salesTable = selectionHelper.getFirst(); // Assign to table buffer the reference to selected record(s)
while (salesTable)
{
info(salesTable.SalesId);
salesTable = selectionHelper.getNext();
}
}
Then I used my own button, not to having to deal with setup for “Release to warehouse”. And I found that the code works flawlessly.
For reference, the same question is also discussed in another forum and I think we found the cause there. The code above is fine; the problem is likely in the fact records are unselected by other code before the handler gets executed.
As always, duplicity leads either to maintenance costs (such as posting this reply with updates) or inconcistent data (if this thread wasn’t updated with information obtained in the other thread).