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
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
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


Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

Martin Ivanov
Giga Sage
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


Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

Sandeep Rajput
Tera Patron
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