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.
Comments
Post a Comment