web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

Hide selected enum values in form control using X++ code

Muhammad Yasir Profile Picture Muhammad Yasir 1,023

Hi,

Today i am going to discuss a very important topic which every one might deals with in routine development tasks.

Many times we come across situation in which we want to restrict the user selection from a particular combo-box. i.e remove some of the elements that are not needed when they are shown in a combo-box on a form.To achieve this behavior Microsoft has given a class just for that purpose. The class is “SysFormEnumComboBox”.

Here is a sample code snippet that depicts how to use this class on a form having a combo-box control: 

Simply 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.
   
    enumSet.add(HMDaysName::Monday);
    enumSet.add(HMDaysName::Wednesday);
    enumSet.add(HMDaysName::Friday);
    

  SysFormEnumComboBox = SysFormEnumComboBox::newParameters(element,                                                 element.controlId(formControlStr(TestForm, ComboBoxCtrl)),  enumName2Id(enumStr(HMDaysName)), enumSet,"Select");
    

    super();
    SysFormEnumComboBox.select(HMDaysName::Friday); // To select value in combo
}







Remember this is only applicable for the unbounded field (control).

That's it. Happy coding :)

This was originally posted here.

Comments

*This post is locked for comments