Get values from MRVS

miyu
Tera Guru

Is there any way to get values from MRVS?
Specifically, I would like to have a record producer variable automatically populated with the result of a calculation based on the following MRVS values.
In the screenshot below, I want to multiply the "金額" and "課金単位数" and set the result of adding each to the "利用料金" variable.
In this screenshot, we see
In this screenshot, 500 x 1 + 600 x 2 = 1,700, so we need to set 1,700 to the "利用料金" variable.
Can I do it?

find_real_file.png

6 REPLIES 6

Murthy Ch
Giga Sage

Hi @miyu 

Can you try this:

function onSubmit() {
    var count = 0;
    var mrvsData = g_form.getValue("u_request_data");  //replace with mrvs internal name
    var mrvsDatastr = JSON.parse(mrvsData);
    for (var i = 0; i < mrvsDatastr.length; i++) {
        count = count + parseInt(mrvsDatastr[i].u_data1) * parseInt(mrvsDatastr[i].u_data2);  //map your variable names
    }
    g_form.setValue("total_value", count);  //map variable name where you want to set
}

Tested in my PDI

find_real_file.png

find_real_file.png

Hope it helps

 

Thanks

Murthy

Hitoshi Ozawa
Giga Sage

Unfortunately, this isn't possble unless a new widget is created.

There are events that will detect addition and modification of mrvs rows but there is no event to detect deletion of mrvs rows. So, deleting a row or selecting delete all can not be detected and the total will be wrong.

The only way without developing a new widget is to create a button on the main form that will update the total when it is pushed.

Vaishnavi Lathk
Mega Sage

Hi,

You can use this

var mrvs = current.variables.multirowvs;
var totalRows = mrvs.getRowCount();
var arr = [];

for (var i = 0; i < totalRows; i++) {
	var value = mrvs.getRow(i).getCell(',mrvs_col').getCellDisplayValue();
	arr.push(value.toString());
}

current.variables.mrvs_to_string = arr.toString();

Regards
Vaishnavi