Client script to check if field is mandatory

Prakash43
Tera Contributor

Hi all i am building an if condition and i want to add a condition where it checks if a particular field is mandatory

How can i achieve this

Thank you in advance

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron

Use following code to get the list of Mandatory fields which are not filled by a user on the form in a client script.

 

var arr = g_form.getMissingFields();

 

Source: https://community.servicenow.com/community?id=community_blog&sys_id=a95d6629dbd0dbc01dcaf3231f961982

View solution in original post

3 REPLIES 3

Martin Ivanov
Giga Sage

Check out this article:

https://community.servicenow.com/community?id=community_blog&sys_id=a95d6629dbd0dbc01dcaf3231f961982

Following this approach, you check if the array contains your field.

Please mark Correct and Helpful if my answer helps you resolve your issue. Thanks!
Martin Ivanov
Community Rising Star 2022

Martin Ivanov
Giga Sage

Hi. If my answer has helped you resolve your issue, Please mark Correct and Helpful. This way, other users may also benefit from the thread. Thanks!
Martin Ivanov
Community Rising Star 2022

Sandeep Rajput
Tera Patron

Use following code to get the list of Mandatory fields which are not filled by a user on the form in a client script.

 

var arr = g_form.getMissingFields();

 

Source: https://community.servicenow.com/community?id=community_blog&sys_id=a95d6629dbd0dbc01dcaf3231f961982