I need help populating a variable from Multi Row Variable Set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 12:20 PM
Heilo, say I have a multi row variable set in a record producer that has two fields, description and percentage. So for example,
Description 1 | 75%
Description 2 | 5%
I have a variable outside the mrvs called total percentage. I want that variable to take the sum of the percentages of in the multi row variable set, when a new row is submitted. So for this example, when Description 2 is submitted, the total percentage is updated to 80%.
I want this to apply to my record producer as well, as I will be able to edit the mrvs from the variable editor in the record producer. I had tried to use an onSubmit client script within the mrvs, but that causes errors in the record producer.
I was wondering if you had suggestions. Thank you.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 01:19 PM
Hi,
You can use an onChange client script, on the MVRS, and the percentage field with script such as:
var cTot = parent.g_form.getValue('total'); //replace total with your variable that contains total
var cVal = newValue;
parent.g_form.setValue('total', Number(cTot) + Number(cVal)); //replace total with your variable that contains total
So this would take a setup like this:
And as you add rows to your MVRS, it'll add them together in the total, like so:
If the set your onChange client script to also work on the target record (it's a checkbox on the form you need to check), then it'll work there too:
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 03:47 PM
Hi AM,
If I remember correctly, onChange() script won't get executed when the row is deleted in mrvs and the total on the form will not get updated and will be incorrect.
AFAIK, the only viable solution that works correctly is to create a button on the form to update the total field when pressed.