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

Chuck Tomasi
Tera Patron

Hi Balaji,



The easiest way I know to submit a form without any mandatory checking is to use the special name 'sysverb_cancel' in   'Action name" field of your UI action. Note, you can only use the UI action name once. It effectively lets you submit the form and ignore any mandatory fields.



UI Actions - ServiceNow Wiki


Hi Chuck,


You mentioned 'sysverb_cancel' ui action name can only be used once. Is this once for each form/table or is it once across the platform?


If you wanted to make it global, you would use the "Global" table and it will appear on the form like Update or Submit.


Thanks for the swift response. I don't want to make it global. I just was wondering if I am able to use this action name on multiple forms/tables.


Since UI actions are tied to a table, you either make it global (and then use the condition field to indicate which table names to use it on) or you need to make one for each table.



An example of



Table: global


Condition: current.getTableName() == 'incident' || current.getTableName() == 'problem'



Allows it to appear only on the incident and problem tables.