MRVS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
I have created a variable set inside the catalog item and i want to run a catalog client script on the catalog item when the MRVS value is added by the end user.I have used the onsubmit catalog client script in the variable set but in the g_form.getValue('mrvs_name').I am not getting any value, is there any other way to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @kali
Use an onSubmit Script on the Main Catalog Item :If you want to validate or process the MRVS data right before the entire form is submitted, you must place the Catalog Client Script on the Catalog Item itself, not inside the variable set.
- Create a new Catalog Client Script.
- Set Applies to to A Catalog Item.
- Set Type to onSubmit.
- Use the MRVS Internal Name
Sample code//update as per your requirement
function onSubmit() {
var mrvsData = g_form.getValue('your_mrvs_internal_name');
if (mrvsData && mrvsData != '[]') {
var parser = JSON.parse(mrvsData);
for (var i = 0; i < parser.length; i++) {
var specificVariableValue = parser[i].internal_variable_name;
if (specificVariableValue == 'some_condition') {
g_form.addErrorMessage('Your validation message.');
return false; // Aborts submission if validation fails
}
}
}
}
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti