erro in mrvs

Suraj_18_18
Tera Contributor

 

Suraj_18_18_2-1748975320380.png

i want to calculate the sum of the value in multi row variable set?
below is the script

function onSubmit() {
//Type appropriate comment here, and begin script below
var count = 0;
var mrvsData = g_form.getValue("abcd"); //replace with mrvs internal name
 
var mrvsDatastr = JSON.parse(mrvsData);
for (var i = 0; i < mrvsDatastr.length; i++) {
count = count + parseInt(mrvsDatastr[i].amt); //map your variable names
 
}
g_form.setValue("aa", count); //map variable name where you want to set

}
 
error = Suraj_18_18_0-1748975269323.png

 

 

Dont know what i am doing wrong

 
5 REPLIES 5

palanikumar
Mega Sage

Hi @Suraj_18_18 

Make sure internal name of MRVS is abcd. 

 

Thank you,
Palani

Thank you,
Palani

Chaitanya ILCR
Kilo Patron

Hi @Suraj_18_18 ,

 

did add the onSubmit client script on the variable set?

 

if yes

add it on the catalog item instead of MVRS

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Suraj_18_18
Tera Contributor

The name is correct

its a record producer.  i tried it in record producer as well. it is working. but i want to perfrom on form

 

@Chaitanya ILCR  @palanikumar  

HI @Suraj_18_18 ,

 

inside mvrs you can only access variables in the mvrs using client script 

 

to access variables outside mvrs you have to use g_service_catalog api

 

g_service_catalog.parent.getValue("variable/MVRS internal name")

 

there is no way to set the value of a variable outside MVRS 

 

you have to keep the onsubmit client script on the record producer itself instead of MVRS

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya