- 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:47 AM
I am getting the alert message but the length is remaining only 1 and it is not setting in that price feild.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 07:25 PM
the code you have share was having below lines:
g_form.setValue('price', mrvsData);
return mrvsData;
Change these lines to below:
this.my_g_form.setValue('price', mrvsData);
return true;
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2023 12:57 AM
I am getting the record count in price feild but not i want to set the price of catalog item according to this count.How to acheive ths can u help me?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2023 01:36 AM
Can you please share you both script?
It is working on my PDI, want to see how it is different in your instance.
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2023 01:54 AM
The solution worked for me but another use case is that now whatever length i am getting i according to that i have to set the price.
i.e length into price of one element
function onSubmit() {
// 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);
this.my_g_form.setValue('quantity', mrvsData);
return true;