Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to disable all the mandatory fields using single function/command.

balaji_prusty1
Giga Guru

Hi All;

In change form   we have lots of mandatory fields depends on the state/type of change. When user need to cancel the change he/she not to ask to fill the mandatory fields depends in which state he/she cancelling.

I can use g_form.setMandatory("FiledName" , false). But again I need to write code for all the mandatory fields (its around 30+) .

Is there any other way to remove/disable all the mandatory fields using single line code.

Thanks in Advance.

Balaji Prusty.

1 ACCEPTED SOLUTION

I am not getting the Close the loop / Answered   under Action....I was looking for this option.



All my previous threads are still open due to this...not sure what/whom need to contact to get this.


View solution in original post

24 REPLIES 24

Hi Anurag;



Thanks it works. I have one question. Is the "g_form.checkMandatory = false" will apply to the fields which are in the Tab at down. here it is not working.



Is there anything I need to put to move out from mandatory for these tab fields ?



find_real_file.png


i dont understand


-Anurag

We have some mandatory fields in the Tab of the change form. It is not working if I put "g_form.checkMandatory = false".



So is there anything need to have to check these fields which are in the Tab ?



find_real_file.png


what is making this field mandatory? client script or something else


-Anurag

All the mandatory field set by UI Policy.



I think "g_form.checkMandatory = false" will not work for Data policy. But here we have all filed set for mandatory using UI Policy.