- 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-05-2023 01:59 AM
Hi,
Can you please post another question?
It is little bit confusing with existing use case.
Please share details like what variable you have on Main form and what should be the price value?
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 04:58 AM
Anil can u please help me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 05:08 AM
Try this to set the value
g_form.setValue('price',mrvsData);
Regards,
Teja
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 05:14 AM
Can you please share updated script?
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 06:09 AM
Script:
function onSubmit() {
this.my_g_form=g_form;
// var mrvsStr = parent.g_form.getValue("additional_users");
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);
g_form.setValue('price', mrvsData);
return mrvsData;
i am only 1 value in alert and not able to set that value in price feild.