2

I use JavaScript to set required level of field based on some selections, the field appears as optional but the form doesn't able to save and says please fill this field.

My code

Xrm.Page.ui.controls.get("new_field").setRequiredLevel("none");

I don't know why this happen i tried to hide the field using this code

Xrm.Page.ui.controls.get("new_field").setVisible(false);

it hides the field but when i press save the field appears again like a charm and cannot save the form.

Hussein Fawzy
  • 525
  • 1
  • 8
  • 15

1 Answers1

6

The script doesnt look quite right,

setRequiredLevel

Xrm.Page.getAttribute("new_field").setRequiredLevel("none");

Visible

Xrm.Page.getControl("new_field").setVisible(false);
James Wood
  • 17,286
  • 4
  • 46
  • 89