Hide selected ENUM values in form control using X++ code(this is only applicable for the unbounded field control)



              Remove some of the elements that are not needed when shown in a combo-box on a form.To achieve this behaviour Microsoft has given a class just for that purpose. The class is “SysFormEnumComboBox”.override the init() of the form and add the code.

  public void init()
    {
        SysFormEnumComboBox     sysFormEnumComboBox;
        Set enumSet = new Set(Types::Enum); // collection of selected values.
        if(CheckLeave.SMJ_CL == NoYes::Yes)
            enumSet.add(SMJ_LeaveCode::CL);
        if(CheckLeave.SMJ_EL == NoYes::Yes)
            enumSet.add(SMJ_LeaveCode::EL);
        if(CheckLeave.SMJ_ML == NoYes::Yes)
            enumSet.add(SMJ_LeaveCode::ML);
        if(CheckLeave.SMJ_Others == NoYes::Yes)
            enumSet.add(SMJ_LeaveCode::Others);
        if(CheckLeave.SMJ_SL == NoYes::Yes)
            enumSet.add(SMJ_LeaveCode::SL);
        SysFormEnumComboBox = SysFormEnumComboBox::newParameters(element,element.controlId(formControlStr(LeaveRequestTable,TypeOfleave)),  enumName2Id(enumStr(SMJ_LeaveCode)), enumSet,"Type of leave");
        super();

    }


Remember this is only applicable for the unbounded field control.













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