Monday, February 17, 2020

How to enable the dimension fields based on the Item selected on the form.

[Form]
public class KMTShipFromWarehouses extends FormRun
{
    InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;

    /// <summary>
    /// InventDimFormDesignUpdate
    /// </summary>
    /// <returns></returns>
    public InventDimCtrl_Frm_EditDimensions inventDimSetupObject()
    {
        return inventDimFormSetup;
    }

    /// <summary>
    /// InventDimFormDesignUpdate
    /// </summary>
    public void init()
    {
        super();
        // This method will be used to show default fields at form startup
        element.updateDesign(InventDimFormDesignUpdate::Init);
    }

    /// <summary>
    /// To Display product dimensions
    /// </summary>
    /// <param name = "mode">InventDimFormDesignUpdate</param>
    void updateDesign(InventDimFormDesignUpdate mode)
    {
        InventDimParm inventDimParmVisible;

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

                    // Use the methods on InventDimParm
                    // to set which dimensions to show when form is initialized
                    inventdimparmvisible.InventSizeIdFlag       = true;
                    inventdimparmvisible.InventColorIdFlag      = true;
                    inventdimparmvisible.InventSiteIdFlag       = true;
                    inventdimparmvisible.InventLocationIdFlag   = true;
                    inventDimFormSetup.parmDimParmVisibleGrid(inventDimParmVisible);
                }
            // Datasource Active
            case InventDimFormDesignUpdate::Active  :
                inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(KMTShipFromWarehouses.ItemId)); //InventDimDisplay is the datasource name.
                inventDimFormSetup.formSetControls( true);
                break;

            // Datasource Field change
            case InventDimFormDesignUpdate::FieldChange :
                inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(KMTShipFromWarehouses.ItemId)); //InventDimDisplay is the datasource name.
                InventDim.clearNotSelectedDim(inventDimFormSetup.parmDimParmEnabled()); // InventDim is referring to datasource name
                inventdimparmvisible.InventSizeIdFlag       = true;
                inventdimparmvisible.InventColorIdFlag      = true;
                inventdimparmvisible.InventSiteIdFlag       = true;
                inventdimparmvisible.InventLocationIdFlag   = true;
                inventDimFormSetup.formSetControls( true);
                break;

            default :
                throw error(strFmt ("@SYS54195", funcName()));
        }
                   
    }

    [DataSource]
    class KMTShipFromWarehouses
    {
         /// <summary>
        /// To Display product dimensions
        /// </summary>
        public int active()
        {
            int ret;
            ret = super();
            element.updateDesign(InventDimFormDesignUpdate::Active);
           
            //If record is saved then allow edit for dimension field is false.
            if (KMTShipFromWarehouses_ds.cursor())
            {
                this.formRun().design(0).controlName('InventoryDimensionsGrid_InventSizeId').allowEdit(false);
                this.formRun().design(0).controlName('InventoryDimensionsGrid_InventColorId').allowEdit(false);
            }
            return ret;
        }

        [DataField]
        class ItemId
        {
            /// <summary>
            /// To Display product dimensions
            /// </summary>
            public void modified()
            {
                super();
   
                element.updateDesign(InventDimFormDesignUpdate::FieldChange);
                InventDim.clearNotSelectedDim(element.inventDimSetupObject().parmDimParmEnabled());
            }

        }

    }

    [DataSource]
    class InventDim
    {
        [DataField]
        class InventSizeId
        {
            /// <summary>
            /// To display site and warehouse
            /// </summary>
            public void modified()
            {
                InventTable                 inventTable = inventTable::find(KMTShipFromWarehouses.ItemId);

                InventItemOrderSetupType    setupType   = InventItemOrderSetupType::Invent;
               
                super();

                inventDim.InventSiteId      = inventTable.inventItemOrderSetupMap(setupType).inventSiteId(inventDim.InventSiteId, inventTable);

                inventDim.InventLocationId  = inventTable.inventItemOrderSetupMap(setupType,InventDim::findOrCreate(inventDim).InventDimId).inventLocationId(inventDim.InventLocationId,inventTable,inventDim.InventSiteId);
               
            }

        }

    }

}


Validate Write method on table

/// <summary>
    /// Validate the required fields
    /// </summary>
    /// <returns>Boolean</returns>
     public boolean validateWrite()
    {
        boolean ret = true;
       
        str errorMessage;

        InventTable     inventTable;
        InventDimParm   inventDimParm;
       
        inventTable   = InventTable::find(this.ItemId);
        inventDimParm =  InventDimParm::activeDimFlag(InventDimGroupSetup::newInventTable(inventTable));

        InventDim kmtInventDim = InventDim::find(this.InventDimId);

        if(inventDimParm.InventSizeIdFlag && !kmtInventDim.InventSizeId)
        {
            errorMessage = strFmt("@SYS26332", Fieldid2PName(tableNum(InventDim),fieldNum(InventDim, InventSizeId)));
        }

        if(inventDimParm.InventColorIdFlag && !kmtInventDim.InventColorId)
        {
            errorMessage = errorMessage + " " + strFmt("@SYS26332", Fieldid2PName(tableNum(InventDim),fieldNum(InventDim, InventColorId)));
        }

        if(kmtInventDim.InventSiteId && !kmtInventDim.InventLocationId)
        {
            errorMessage = errorMessage + " " + strFmt("@SYS26332", Fieldid2PName(tableNum(InventDim),fieldNum(InventDim, InventLocationId)));
        }

        if(errorMessage)
        {
            ret = checkFailed(errorMessage);
        }

        else
        {
            ret = super();
        }

        return ret;
    }

8 comments:

  1. احدث اساليب الصيانة فى الاسكندرية لان الصيانة السليمة يجب ان تتم على أيدي متخصصين لدينا فريق عمل متميز من المهندسين والفنيين والمتخصصين .متخصصون فى صيانة واصلاح الأجهزة المنزلية , نحن الأسرع فى الوصول اليك ، فريق الصيانة فى خدمتكم على مدار اليوم , اتصل نصلك أينما كنت
    نتميز عن غيرنا بالإلتزام مع العملاء ، العمل الجاد ، الاحترافية في الصيانة , توفير خدمات راقية المستوى , فريق عمل مدرب بإحترافية
    صيانة كريازي بالاسكندرية
    توكيل صيانة كريازي بالاسكندرية
    صيانة ثلاجات كريازي بالاسكندرية
    توكيل صيانة ثلاجات كريازي بالاسكندرية
    رقم صيانة كريازى بالاسكندرية
    صيانة ديب فريزر كريازى بالاسكندرية
    توكيل صيانة كريازي بالاسكندرية
    صيانة كريازي بالاسكندريه
    صيانه كريازي بالاسكندريه

    ReplyDelete
  2. https://www.youtube.com/playlist?list=PLWSxgDbjVWTjxvgnaAZ0iK8o5dYHAYhrq

    Collection of Microsoft ERP Clips || ERP Licensing, Technical, Functional ,Manager Learning Videos Listing

    ReplyDelete
  3. I am so delighted I found your weblog, I really found you by accident,
    And would just like to say thank you for a fantastic post and a all round entertaining blog (I also love the theme/design), SOMEONE CAN MAKE FAKE DRIVERS LICENSE THAT WORKS FROM HOME SAME AS THE LICENSE ISSUED I don't have time to go through it all at the minute but I have bookmarked it and also added your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the excellent job.

    Y’all don’t forget to join this DMV EXPERTS TELEGRAM GROUP for more information about new drivers license and updated materials being used along the production process of the DL . You can also take advantage to learn and meet many Experts who will guide you on numerous techniques for anyone who love hacking and don’t know how to go about it .

    ReplyDelete

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// &l...