Get the selected records of a form datasource
Sometime we have requirement that we need to do some operation on the selected records of a form.
on the below code, we may have button on the CustTable form and datasource property should be custTable in this case to access the record from CustTable table. when we select multiple record on the custTable form and click that menu item button then in the below class, we can get the selected records by using the standard class MultiSelectionHelper.
if only single record is selected then still it will work.
public static void main(Args _args)
{
MultiSelectionHelper selectionHelper;
CustTable
custTable;
if (_args.caller() && _args.dataset() == tableNum(CustTable))
{
selectionHelper = MultiSelectionHelper::createFromCaller(_args.caller());
custTable =
selectionHelper.getFirst();
while (custTable)
{
info(strFmt("Select account number is %1",custTable.AccountNum));
custTable =
selectionHelper.getNext();
}
}