- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 08:09 PM
Hi Guys,
I have a requirement to setup a script to verify user needs to fill in minimum 4 records in MRVS. Not sure how to write on the client script? I tried below one but it doesn't work.
function onSubmit() {
//Type appropriate comment here, and begin script below
if(g_form.getValue('list_authorized_signatories_four_signers_minimum') < '4'){
g_form.alert('You must enter at least 4 signers');
return false;
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 08:56 PM
Hi Bird,
Following script will show an error message when there is less than 4 rows in mrvs field named "list_authorized_signatories_four_signers_minimum".
Number of rows is an integer so should compare with integer 4 and not string '4'
To display an error message, use g_form.addErrorMessage(). There is no such method as g_form.alert().
function onSubmit() {
var mrvs = g_form.getValue('list_authorized_signatories_four_signers_minimum');
var jsonMrvs = JSON.parse(mrvs);
if (jsonMrvs.length < 4) {
g_form.addErrorMessage('You must enter at least 4 signers');
return false;
}
}
Execution example output.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 01:50 PM
Brilliant solution! Thank You!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 08:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2025 04:20 AM
Hi All,
I wrote the same code, but it is not working.
Can you pelase check the issue:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2025 05:29 AM
Can you please raise a new question as this is an old thread and tag me there?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2025 03:45 PM
Thanks Ankur.
Jus posted the query: