Making section mandatory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2016 11:06 PM
Hi,
I'm trying to make a section mandatory on form. Can anyone please provide any pointers.
Thanks.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2016 11:17 PM
Hi Vani,
Either you can make any field of the section Mandatory onLoad or you can check it onSubmit as bellow. Write a Client script onSubmit to check and show alert message.
if (g_form.getControl('field_1') && g_form.getControl('field_2') && g_form.getControl('field_3')){
if(g_form.getValue('field_1') == '' || g_form.getValue('field_2') == '' || g_form.getValue('field_3') == ''){
g_form.setMandatory('field_1', true);
g_form.setMandatory('field_2', true);
g_form.setMandatory('field_3', true);
alert('Please complete the mandatory fields');
return false;
}
}
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2016 11:17 PM
I guess if you make fields under that section mandatory by Ui Policy, the section will itself become mandatory.
PS: Hit like, Helpful or Correct depending on the impact of the response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2016 11:45 PM
Hi,
We have many questions in the section, of which all are mandatory. Mandatory pop-up should display only the section name, but not the entire questions.
So, looking for the making section mandatory.
Thanks
Vani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2016 12:49 AM
Hi Vani,
you can write a client script onSubmit to check and show message accordingly,
for example,
if(g_form.getValue('yourFieldName1') == '' || ..so on...)
{
// give the section mandatory message
alert('Section XXX mandatory, please fill the all fields etc...');
return false;
}
If this is a catalog item form, then you can use catalog UI policies to control it too.
More details: Service Catalog UI Policy - ServiceNow Wiki
BR,
/Suraj