UI Policy - set all fields to Mandatory & Visible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 09:23 AM
Hello all,
I create a UI policy to make all field ServiceNow Instance visible and mandatory only if the Change Category is ServiceNow.
The question is: how can I select all fields instead of do it one by one?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 10:17 AM
As best practice, you should use UI policy to make field mandatory.
But you can use the getEditableFields call in a client script to make everything mandatory. This will only be effective when viewing the form, as all client side scripts are.
function onLoad(){
var fields = g_form.getEditableFields();
for(i=0; i<fields.length; i++){
g_form.setMandatory(fields[i],true);
}
}
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 10:53 AM
Yes, I did use UI Policy and there are a lot fields in the form. So I need to add it one by one?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 10:56 AM
If you don't want to do it using UI policy, then you can configure onload client script and use my below code in client script to make all fields mandatory.
You don't have to specify each field in client script.
Regards,
Sachin
function onLoad(){
var fields = g_form.getEditableFields();
for(i=0; i<fields.length; i++){
g_form.setMandatory(fields[i],true);
}
}
Regards,
sachin