I need to add the vendor batch number to the On-hand form in D365. I was able to add it using the code below, and it worked correctly for the first item I tested. However, after changing the display dimensions, I began receiving the error shown below. Could you please help me identify what went wrong?
[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);
InventDimParm inventDimParmGroupBy = InventDimParm::orParmsAll(dimParmLockedRightClick, dimParmVisibleGrid);
if (inventDimParmGroupBy.InventBatchIdFlag)
{
if (!_inventSum_DS_Query.dataSourceTable(tableNum(InventBatch)))
{
_inventSum_DS_Query.dataSourceTable(tableNum(InventDim)).addDataSource(tableNum(InventBatch), 'PBFInventBatch');
}
_inventSum_DS_Query.dataSourceTable(tableNum(InventBatch)).relations(false);
_inventSum_DS_Query.dataSourceTable(tableNum(InventBatch)).joinMode(JoinMode::OuterJoin);
_inventSum_DS_Query.dataSourceTable(tableNum(InventBatch)).clearLinks();
_inventSum_DS_Query.dataSourceTable(tableNum(InventBatch)).addLink(fieldNum(InventDim, inventBatchId), fieldNum(InventBatch, inventBatchId));
_inventSum_DS_Query.dataSourceTable(tableNum(InventBatch)).addLink(fieldNum(InventSum, ItemId), fieldNum(InventBatch, itemId), tableStr(InventSum));
_inventSum_DS_Query.dataSourceTable(tableNum(InventBatch)).addGroupByField(fieldNum(InventBatch, PdsVendBatchId));
}
}
}