Hi guys, Today we see how to Display inventory dimensions dynamically in D365Fo.
For New Table and New Form
1.Create new fields in table using (InventDimId) and create relation with InventDim
2.Add InventDim datasource in form and join (Inner Join) it with Datasource which contains your item id (new Table)
3.Create a new group under your gird. Set its datasource property to InventDim and Data group property to InventoryDimesions.
4.Add InventDimParmFixed Display menu item to your Tab->action pane menu.
Write code on form Methods
class declaration
InventDimCtrl_Frm_EditDimensions inventDimFormSetup;
Method inventDimSetupObject (New)
public InventDimCtrl_Frm_EditDimensions inventDimSetupObject()
{
return inventDimFormSetup;
}
Method init (New)
public void init()
{
super();
// This method will be used to show default fields at form startup
element.updateDesign(InventDimFormDesignUpdate::Init);
}
Method updateDesign (New) on form
void updateDesign(InventDimFormDesignUpdate mode)
{
InventDimParm inventDimParmVisible;
switch (mode)
{
// Form Init
case InventDimFormDesignUpdate::Init :
if (!inventDimFormSetup)
inventDimFormSetup = InventDimCtrl_Frm_EditDimensions::newFromForm(element);
inventDimFormSetup.parmSkipOnHandLookUp( true);
inventdimparmvisible.inventsiteidflag = true;
inventDimFormSetup.parmDimParmVisibleGrid(inventDimParmVisible);
// Datasource Active
case InventDimFormDesignUpdate::Active : inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(<TableName>.ItemId));
inventDimFormSetup.formSetControls( true);
break;
// Datasource Field change
case InventDimFormDesignUpdate::FieldChange :
inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(<TableName>.ItemId));
InventDim.clearNotSelectedDim(inventDimFormSetup.parmDimParmEnabled()); // InventDim is referring to datasource name
inventDimFormSetup.formSetControls( true);
break;
default :
throw error(strFmt (“@SYS54195”, funcName()));
}
}
Data source active (New)
public int active()
{
int ret;
ret = super();
element.updateDesign(InventDimFormDesignUpdate::Active);
return ret;
}
ItemId Modified (new)
public void modified()
{
super();
element.updateDesign(InventDimFormDesignUpdate::FieldChange);
InventDim.clearNotSelectedDim(element.inventDimSetupObject().parmDimParmEnabled());
}
Keep Daxing!!