Sunday, January 9, 2022

Loop through selected records of a grid using MultiSelectionHelper class in D365 FO

Multi-selection helper class

If a grid has the Multselection property enabled you can select more than one record.

If you want to programmatically loop through selected records just follow this code using MultiSelectionHelper class


void clicked() 

   InventItemGroup itemGroup; 

   MultiSelectionHelper helper = MultiSelectionHelper::construct();

   helper.parmDatasource(InventItemGroup_DS);

   itemGroup = helper.getFirst();

   while (itemGroup.RecId != 0)

   {

       info(itemGroup.ItemGroupId);

       itemGroup = helper.getNext();

   } 

}


Loop through selected records of a grid with MultiSelectionHelper class