Search code examples
formsgridaxaptadynamics-ax-2012x++

Why MultiSelectionHelper with Form View DataSource doesn't stop?


I'm using `MultiSelectionHelper, my code is this :

MyView currentRecord;
MultiSelectionHelper helper = MultiSelectionHelper::construct();
helper.parmDatasource(MyView_ds);

currentRecord = _helper.getFirst();

while (currentRecord)
{
   // to do action
   currentRecord= helper.getNext();
}

But the problem in while loop not stop when see in Debug currentRecord.RecId = 0 , map = Common

The cycle don't stop, and continue without record!


Solution

  • Maybe you need to change your while condition like the following:

    MyView currentRecord;
    MultiSelectionHelper helper = MultiSelectionHelper::construct();
    helper.parmDatasource(MyView_ds);
    
    currentRecord = _helper.getFirst();
    
    while (currentRecord.RecId != 0)
    {
       // to do action
       currentRecord= helper.getNext();
    }
    

    If this doesn't work please refresh the cache and data from tools menu. This will surely solve the problem.