Friday 31 May 2013

Using the MultiSelection Helper Class in AX 2012


MultiSelection Helper :

 
Think of a Scenario in which you have to select all the records in a grid by means of that small check box at the top left corner of a grid and based on that selection you have to make decisions on the records returned .

Although , it looks very simple but in reality its not the case . But you don't need to worry now because the
" MultiSelection Helper Class " does this for you , in a fairly simple way .

Just have a look at the example given below.

In case of a form Override the Clicked event of the button that is used to fetch the records  and replace this code to that method with your own data source.

void clicked()
{
    CustPaymModeTable custPaymModeTablelocal;
    MultiSelectionHelper helper = MultiSelectionHelper::construct();

    helper.parmDatasource(custPaymModeTable_ds);
    custPaymModeTablelocal = helper.getFirst();
  
    while (custPaymModeTablelocal.RecId != 0)
    {
        info(custPaymModeTablelocal.PaymMode);

        custPaymModeTablelocal = helper.getNext();
    }
}

                    
The records are fetched in between the get First and get Next methods and that's where you can perform your desired Operations.

I believe it was simple .. Have Fun !!

0 comments:

Post a Comment