crm - Javascript - Set Required level doesn't work - Stack Overflow

admin2025-04-20  0

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.

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.

Share Improve this question asked Sep 20, 2015 at 20:33 Hussein FawzyHussein Fawzy 5351 gold badge8 silver badges15 bronze badges 3
  • Which entity and field? – James Wood Commented Sep 20, 2015 at 20:51
  • Case entity and the field is lookup i created – Hussein Fawzy Commented Sep 21, 2015 at 5:14
  • 1 To clarify, getControl = form actions (Disable, Visible...) getAttribute = value actions (get, set, required level...) – Sxntk Commented Sep 21, 2015 at 18:21
Add a ment  | 

1 Answer 1

Reset to default 6

The script doesnt look quite right,

setRequiredLevel

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

Visible

Xrm.Page.getControl("new_field").setVisible(false);
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745123334a286278.html

最新回复(0)