get MVRS values in catalog client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 03:13 AM
var mvrsvalues= JSON.parse(g_form.getValue('mvrs_name'));
g_form.addInfoMessage(mvrsvalues)
is it not possible to get mvrs json in catalog client script ?
I'm just trying to log the json string and it doesnt work, trying in onchange of a variable of MVRS using catalog client script for a catalog item
- Labels:
-
Request Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 03:15 AM
Hi refer the links below
https://community.servicenow.com/community?id=community_article&sys_id=2a508caedbf47f48d82ffb243996198f
https://community.servicenow.com/community?id=community_question&sys_id=37c35df8dbb6d850fb115583ca96195e
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 03:16 AM
Hello
Yes
try below script
var mvrsvalues= JSON.parse('mvrs_name');
g_form.addInfoMessage(JSON.stringify(mvrsvalues)); // to print the JSON
//Below code is to access the JSON elements
for(var i=0; i<mvrsvalues.length;i++)
{
g_form.addInfoMessage(mvrsvalues[i].your_variable_name_in_mvrs);
}
Please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 03:57 AM
And for you question to compare two values you can use below script
But change you script to on submit in on change you cant do it
function onSubmit() {
var value = g_form.getValue("your mvrs name");
var mvrsArr = JSON.parse(value);
var comparedValue = compareValues(g_form.getValue("your column variable back end name to check "), mvrsArr))
alert(comparedValue);
}
function compareValues(valueToBeChecked, mutiRowArray) {
for (var i = 0; i < mutiRowArray.length; i++) {
if (mutiRowArray[i].your_variable_back_end_name == valueToBeChecked) {
return 'valueFound';
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 03:18 AM
Hi,
you can access complete JSON of MRVS only in onChange or onSubmit catalog client script which applies to either Catalog item or a variable set(not MRVS)
You cannot access complete JSON if you are writing onChange script on 1 of the variable within MRVS
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader