Display inventory dimension control on a Form in D365

If we want to add inventory dimensions we must need the join of our table with the inventDim table. For this, we need itemid field. if your table doesn't contain this field First drag and drop the EDT (InventDimId) in your table.


Add InventDim data source in your main form and join (Inner Join) it with your data source  I used InventTrans as an example table. you can use any table.


Add a menu item button and a grid and add those fields that you want to show into the grid


Add InventDimParmFixed Display menu item to your action pane menu. 

Create a new group under your grid. Set its data source property to InventDim and Data group property to InventoryDimesions.



Code

[Form]
public class RM_DisplayInventDim extends FormRun
{
    InventDimCtrl_Frm_EditDimensions inventDimFormSetup;
    public void init()
    {
        super();
        element.updateDesign(InventDimFormDesignUpdate::Init);
    }
    public InventDimCtrl_Frm_EditDimensions inventDimSetupObject()
    {
        return inventDimFormSetup;
    }
    void updateDesign(InventDimFormDesignUpdate mode)
    {
        InventDimParm  inventDimParmvisible;
        switch (mode)
        {
            case InventDimFormDesignUpdate::Init   :
            if (!inventDimFormSetup)
                {
                    inventDimFormSetup = InventDimCtrl_Frm_EditDimensions::
                                                    newFromForm(element);
                    inventDimFormSetup.parmskipOnHandLookUp(true);
                    inventDimFormSetup.parmDimParmVisibleGrid(inventDimParmvisible);
                }
                    break;
 
            case InventDimFormDesignUpdate::Active :             
                inventDimFormSetup.formActiveSetup(InventDimGroupSetup::
                                            newItemId(InventTrans.ItemId));
                inventDimFormSetup.formSetControls(true);
                break;
            case InventDimFormDesignUpdate::fieldChange   :
                inventDimFormSetup.formActiveSetup(InventDimGroupSetup::
                                            newItemId(InventTrans.ItemId));
                Inventdim.clearNotSelectedDim(inventDimFormSetup.parmDimparmEnabled());
                inventDimFormSetup.formSetControls(true);
                break;
            default:
                throw error(strFmt ('@RM_Labels:RM_error2', funcName()));
        }
    }
    [DataSource]
    class InventTrans
    { 
        public int active()
        {
            int ret;
            ret = super();
            element.updateDesign(InventDimFormDesignUpdate::Active);
            return ret;
        }
    }


Comments

Popular posts from this blog

Batch jobs stuck on WAITING status in AX 2012

Electronic Reporting For Beginners

Computed column and virtual field in D365