- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 02:50 AM
I have written catalog client script on variable set.Whenever i add record in multirow variable set i need to get record count in alert.This script is working when i exceute in TRY IT Scetion. But this script is not working in sp portal when i add row in multi row variable set.
I am geeting the error--Error There is a JavaScript error in your browser console
Script:
function onSubmit() {
var mrvsStr = parent.g_form.getValue("additional_users");
var mrvsData = JSON.parse(mrvsStr).length + 1;
//var obj = JSON.parse(mrvsStr);
//var length1 = obj.length;
alert('Number of rows in MRV is - ' + mrvsData);
//parent.g_cart.setQuantity(mrvsData);
parent.g_form.setValue('price',mrvsData);
return true;
Please help me why this script is not working in portal.
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 06:34 AM
Hi,
You have to put below line in separate onLoad client script created on catalog Item (Not in variable set client script)
this.my_g_form=g_form;
and use the script provided by me in onSubmit client script for portal:
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 04:01 AM
can you share the error as well
Navigate to inspect element - > console and send a screenshot of that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 04:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 05:51 AM
Remove parent and use as below
var mrvsStr = g_form.getValue("additional_users");
Thanks,
Manjusha Bangale

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 04:09 AM
hi,
Please ty below API to access parent form variables including MRVS.
also check below link:
https://rubenferrero.com/servicenow/multi-row-variable-set-form-communication/
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 04:30 AM - edited ‎04-04-2023 04:31 AM
Hi,
Below part work in portal view:
add below line in onLoad client script of your cat Item (on Main form).
this.my_g_form = g_form;
Update your onSubmit client script like below. (only for portal)
function onSubmit() {
var mrvsStr = this.my_g_form.getValue('additional_users') || '[]';
var mrvsData = JSON.parse(mrvsStr).length + 1;
//var obj = JSON.parse(mrvsStr);
//var length1 = obj.length;
alert('Number of rows in MRV is - ' + mrvsData);
//parent.g_cart.setQuantity(mrvsData);
this.my_g_form.setValue('price', mrvsData);
return true;
}
Note: You may need to create dedicated scripts for portal and Native UI. or use logic in same script for both UI and use if condition to run script part based on UI.
Thanks
Anil Lande