AX / D365FO – Get Multiple selected rows from a caller Form
class SelectMultipleRowsJob
{
public static void main(Args _args)
{
YourTableName yourTableName; //Table name
FormDataSource yourTableName_ds; //Data source attached with the specified form from where this job is running
MultiSelectionHelper helper;
if(_args) //Checking that the args are coming from the form
{
if(_args.dataset() == tableNum(YourTableName)) //Checking that the arguments have the dataset equals to our specific table
{
yourTableName_ds = _args.callerFormControl().formRun().dataSource(); //Getting the data source from argument and assigning it to the object created above
helper = MultiSelectionHelper::construct();
helper.parmDatasource(yourTableName_ds);
yourTableName = helper.getFirst(); //Getting the first row
while (yourTableName)
{
info(strFmt("%1", yourTableName.FieldName)); //Printing just to check whether we get the data or not
//You can do your work here.....
yourTableName = helper.getNext(); //Reading the next row
}
}
}
}
}
Leave a comment