Hide Enum value based on condition at run time (bounded)



                Here is code sample to hide ENUM elements from a FORM at run time.  For reference purpose I’m using leave request process form. In this every worker have different type of leaves
for example, some worker can able to apply EL some of can eligible to apply EL women worker only eligible to apply ML. So we supposed to modified ENUM value based on worker.
(ENUM = SMJ_LeaveCode)








Now i want to show only first two values while selecting on SO, to achieve this override the form control method as below


[Control("ComboBox")]


    class SMJ_LeaveRequestLine_TypeOfleave
    {
        /// <summary>
        ///
        /// </summary>
        public void enter()
        {
            super();
            hcmworker CheckLeaveType = hcmworker::findByPersonnelNumber(hcmworker::find(hcmworker::userId2Worker(curUserId())).PersonnelNumber);//this is for get current logged in worker id  
            if(CheckLeaveType.SMJ_CL == NoYes::No)
                this.delete(enum2str(SMJ_LeaveCode::CL));
            if(CheckLeaveType.SMJ_EL == NoYes::No)
                this.delete(enum2str(SMJ_LeaveCode::EL));
            if(CheckLeaveType.SMJ_ML == NoYes::No)
                this.delete(enum2str(SMJ_LeaveCode::ML));
            if(CheckLeaveType.SMJ_Others == NoYes::No)
                this.delete(enum2str(SMJ_LeaveCode::Others));
            if(CheckLeaveType.SMJ_SL == NoYes::No)
                this.delete(enum2str(SMJ_LeaveCode::SL));
        }

    }




Here i select only following leave type

  • CL,
  • EL  and 
  • Others 


Final out put :



Comments

Popular posts from this blog

SSRS Report using Controller , Contract and RDP classes in D365

Exporting data to Excel through X++ code

COC for Form level method

How to pass the parameter from one form to another in Dynamic365

Multi Select Lookup in SSRS Report in D365