Translate

Showing posts with label Select multiple records on the form to update together. Show all posts
Showing posts with label Select multiple records on the form to update together. Show all posts

Wednesday, October 30, 2019

MultiSelectHelper class - Select multilpe records in form grid to update the data altogether once.

1) Create a class that extends the runbase class.

2) write a main method to handle the class methods and its arugments

In main method declare the below helper class
 MultiSelectionHelper                helper;//multiselect

and also validate the class is invoked based on correct paramaters and caller

for example: if(_args && _args.dataset() == tableNum(VendInvoiceInfoTable))//if class is invoked from table VendInvoiceInfoTable.

also initialize the helper class as below
 helper  = MultiSelectionHelper::createFromCaller(_args.caller());

read the first record as vendInvoiceInfoTable = helper.getFirst();

and next records as vendInvoiceInfoTable = helper.getNext();

loop the multiple records recading
while (vendInvoiceInfoTable)
{
info(vendInvoiceInfoTable.num);

vendInvoiceInfoTable = helper.getNext();

}

refresh the caller form - formDataSourceRefresh(VendInvoiceInfoTable); this will help to show the data updated inmmidiately after the function runs.

Invoke this class using Action menu item and please make sure to setup the menu property :MultiSelect to YES whereever you add this menuitem on the form



complete example:

MultiSelectionHelper                helper;//multiselect
    if(_args && _args.dataset() == tableNum(VendInvoiceInfoTable))
    {
     
        helper  = MultiSelectionHelper::createFromCaller(_args.caller());
        vendInvoiceInfoTable = helper.getFirst();
   
        if (pendingInvoiceUpdate.prompt())
        {
            while (vendInvoiceInfoTable)
            {
                if(vendInvoiceInfoTable ))
                {
               info(vendInvoiceInfoTable.num);
                }
                vendInvoiceInfoTable = helper.getNext();
            }
            formDataSourceRefresh(VendInvoiceInfoTable);//refresh the caller form
        }
    }