Hide selected enum values in form control using X++ code
Views (4144)
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.
{
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.

Like
Report

*This post is locked for comments