How to send enum parameters to forms in D365
step1: create a base enum with atleast two elements in it.
ex: My base enum is Opearations it contains two elements
1) Full Operation
2) Read Only
step2: after creating base enum go to any menu item
step3: go to menu item properties
In the properties set Enum Type Parameter with base enum name (Operations)
and also set Enum Parameter with any base enum element (Full Operation or Read Only).
step4: go to the form which belongs to that display menu item
step5: override the init method of the form
copy and paste the following code
Operations mode;
public void init()
{
super();
if (element.args())
{
//Handle the scenario where the args sends in a TutorialVehicleServiceWorkbenchMode enum.
//Use the passed in enum to control whether you can edit the form or not.
if (element.args().parmEnumType() == enumNum(Operations))
{
mode = element.args().parmEnum(); //here we are storing whatever the valu present in the menu item of this form (i.e..,enum parameter property)
element.changeFormBasedOnMode();
}
}
}
public void changeFormBasedOnMode()
{
switch (mode)
{
case Operations::FullOperation :
Sports_ds.allowEdit(true);
Sports_ds.allowDelete(true);
Sports_ds.allowCreate(true);
//disable buttons in button group
FormButtonGroupControl1.enabled(true);
break;
case Operations::ReadOnly:
Sports_ds.allowEdit(false);
Sports_ds.allowDelete(false);
Sports_ds.allowCreate(false);
//disable buttons in button group
FormButtonGroupControl1.enabled(false);
break;
}
}
Comments
Post a Comment