Thursday, December 8, 2022

How to add new data source to On-hand List Form in D365FO.

 I got a requirement to add Item group field in On-hand List Form. For this I have followed the below process.

Item group is stored in ' InventItemGroupItem' Table.

Step 1:  Added relation in InventSum table.


Step 2:  Added InventItemGroupItem table in form data source and need to given the below properties.

Step 3:  Write the below code in 'modifyQueryBasedOnDatasourceName' method.

[ExtensionOf(classStr(InventDimCtrl_Frm_OnHand))]
final class InventDimCtrl_Frm_OnHand_Extension 
{
    public void modifyQueryBasedOnDatasourceName(
        Query          _inventSum_DS_Query,
        str            _inventSum_DS_Name,
        FormDataSource _inventDim_DS)
    {
        next modifyQueryBasedOnDatasourceName(_inventSum_DS_Query,_inventSum_DS_Name,_inventDim_DS);

        QueryBuildDataSource qbds = _inventSum_DS_Query.dataSourceTable(tableNum(InventItemGroupItem));
        qbds.addGroupByField(fieldNum(inventItemGroupItem,ItemGroupId));
        qbds.addGroupByField(fieldNum(inventItemGroupItem,itemdataAreaID));
    }

}


Keep Daxing!!