How to create form with Display Inventory Dimensions in AX 2012 with X++

Create a table with fields: ItemId, InventdimId


Add these methods to your Form :

public class FormRun extends ObjectRun
{
    InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;    
}

public void  init()
{
    super();  
    element.updateDesign(InventDimFormDesignUpdate::Init);
}


Object inventDimSetupObject()
{
    return inventDimFormSetup;
}

void updateDesign(InventDimFormDesignUpdate mode)
{
    switch (mode)
    {
        case InventDimFormDesignUpdate::Init           :
            if (!inventDimFormSetup)
            {
                inventDimFormSetup  = InventDimCtrl_Frm_EditDimensions::newFromForm(element);
            }
            //inventDimFormSetup.parmSkipOnHandLookUp(true);

        case InventDimFormDesignUpdate::Active         :
            //allow choosing dimension 
inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(DICPromotionAmountItem.ItemId));
            inventDimFormSetup.formSetControls(true);
            break;
        case InventDimFormDesignUpdate::FieldChange    :
            inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(DICPromotionAmountItem.ItemId));
            InventDim_PromotionAmountItem.clearNotSelectedDim(inventDimFormSetup.parmDimParmEnabled());
            inventDimFormSetup.formSetControls(true);           
            break;
        default : throw error(strFmt("@SYS54195",funcName()));
    }
}

Override these methods in Form>>Datasource.

public boolean validateWrite()
{
    boolean ret;
    DICPromotionAmountItem.InventDimId = InventDim::findOrCreate(InventDim_PromotionAmountItem).InventDimId;

    ret = super();

    return ret;
}

public int active()
{
    int ret;
    ;
    ret = super();
    element.updateDesign(InventDimFormDesignUpdate::Active);
    return ret;
}

public void modified()
{
 ;
super();
element.updateDesign(
InventDimFormDesignUpdate::FieldChange);
inventDim.clearNotSelectedDim(element.inventDimSetupObject().parmDimParmEnabled());

}

Override method modified for ItemId field in your datasource
public void modified()
{
    ;
    super();
    element.updateDesign(InventDimFormDesignUpdate::FieldChange);
    InventDim_PromotionAmountItem.clearNotSelectedDim(element.inventDimSetupObject().parmDimParmEnabled());
}
In Action Pane >> create a new menuitembutton set bellow the propertitys 
 Caption  : DisplayDimensions
 Menuitemtype  : display
MenuItemName :   InventDimParmFixed


No comments:

Post a Comment