Loop through a variable in MRVS to check the condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 12:52 AM
I have a variable in a form within multi row variable set.
The variable is a YES/NO field. I wanted to check for every row added the if at any row "no" is selected on the variable the form should not be submitted
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 01:17 AM
Hello Karan
Can you specify where are you facing issue? How much of code is completed?
This article may help you:
Accessing Multi-Row Variable Set value
Please mark as Correct Answer and Helpful, if applicable.
Thank You!
Abhishek Gardade
ServiceNow MVP 2020
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 01:29 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 02:19 AM
yes you can do that.
Here we go.
Sample Code:
function onSubmit() {
var gr = JSON.parse(g_form.getValue('apps_enable'));
for(var i = 0 ; i < gr.length ; i ++){
if(gr[i].set == 'No' || gr[i].set1 =='No'){
alert(' the column contains No ');
return false;
}
}
}
Note: apps_enable is the internal name of your MRVS .
screenshot for reference.
Note: I tested it and working fine.
If my answer helped you, mark it as correct and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 02:30 AM
Hi Harshvardhan , will this script apply to variable set or item?