Wednesday, December 13, 2017

Get selected records in a grid on a form AX - X++

To get selected record(s) in a grid in AX, we use the MultiSelectionHelper class. To achieve that, follow the steps below:

1.  Create a command button on the form and override the clicked method.
2.  Insert the code below:
 

void clicked()
{
    MultiSelectionHelper          selectionHelper = MultiSelectionHelper::construct();//Create instance of class
    Set                           selectedRecords = new Set(Types::Record);//Declare a set of type record
    MyLinesTable                  tableLines; //Your table buffer
    super();
 
    selectionHelper.parmDataSource(MyLinesTable_DS); //Set the datasource
    tableLines  = selectionHelper.getFirst(); //assign to table buffer the reference to selected record(s)
 
    if (tableLines.RecId)
    {
        while (tableLines)
        {
            selectedRecords.add(tableLines);
            info(strFmt('Selected record.. %1',tableLines.myField));//Display selected record
            tableLines = selectionHelper.getNext();
        }
    }
}
 
3. Select record(s) on the grid then click on the command button to view the selected records.

Conversion of Disposition code, code was not specified - Error in D365 F&O for inter company purchase order return

 We crated the return order for inter company purchase order  and created a Item Arrival Journal through Arrival Overview in corresponding c...