Make all variables not mandatory on RITM and TASK view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 05:20 AM
Hello!
Is it possible to make all variables not mandatory for RITM and TASK view using onload client script? Without the use of DOM manipulations
UI policy is uncomfortable in this case, because I have 100 variables in cat item
I know that we can make read-only all variables with g_form.setVariablesReadOnly(true). Is there something for mandatory?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 05:31 AM
Hi @Marina15,
To make all variables mandatory in catalog item try below script
var fields = g_form.getEditableFields();
for(var x=0;x<fields.length;x++){
g_form.setMandatory(fields[x],true);
}
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
Regards,
Mohan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 06:17 AM
Hello! It doesn't work for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 05:32 AM
Hello @Marina15 ,
If you are just looking for something like g_form.setVariablesReadOnly(true) you can use g_form.setMandatory("work_notes", true) to make the fields mandatory.
But instead if you are making the fields mandatory through UI policy on catalog form. Then you just need to uncheck the two boxes '' and 'Applies on Requested Items' . Thus the Ui policy wont apply on RITM and TASK view and the fields will be non mandatory.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.