- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 08:38 AM
Hello,
I have a requirement to add rows to a multirow variable set based off of a selected value from another variable. The dropdown will be numbered 1 through 5. If 4 is selected, 4 single line text rows get inserted. The same applied to all the other selections.
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 01:01 PM
Let's take it down a level; this this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var mvrs = [];
for (var i = 0; i < newValue; i++) {
var tempObj = {};
tempObj.test_report_number = '';
mvrs.push(tempObj);
}
g_form.setValue('multi_row_variable_set_test', JSON.stringify(mvrs));
}
I hope this helps!
If this was helpful or correct, please be kind and remember to click appropriately!
Michael Jones - Proud member of the CloudPires team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 10:52 AM
I have 2 fields on my Record Producer:
- 1 variable: Select Box with 1 - 5
- MRVS: "Multi Row Variable Set Test" with 1 variable "Test Report Number"
When a dropdown selection is made, rows should be added based on the selected number from the dropdown.
Sorry for the confusion

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 10:58 AM
What is the Internal Name of your MVRS and the name of your variable (not the labels) for example, are they multi_row_variable_set_test and test_report_number?
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 11:07 AM
MRVS Internal name: multi_row_variable_set_test
Variable Name from MRVS: test_report_number
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
alert(g_form.getValue('multi_row_variable_set_test'));
// output is [{"singlelinetext":"1"},{"singlelinetext":"2"},{"singlelinetext":"3"},{"singlelinetext":"4"}]
var mvrs = JSON.parse(g_form.getValue('multi_row_variable_set_test'));
for (var i = 0; i <= 4; i++) {
var tempObj = {};
tempObj.test_report_number = i + 4;
mvrs.push(tempObj);
}
g_form.setValue('multi_row_variable_set_test', JSON.stringify(mvrs));
//new value is [{"singlelinetext":"1"},{"singlelinetext":"2"},{"singlelinetext":"3"},{"singlelinetext":"4"},{"singlelinetext":4},{"singlelinetext":5},{"singlelinetext":6},{"singlelinetext":7},{"singlelinetext":8}]
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 11:25 AM
Try this, for example. Based on what you've shared, this onchange should add X blank rows to your MVRS based on what is selected in your select box, adding more each time you change the box and preserving whatever data might already be present.
If you want it to clear everything out and only add the empty lines based on the select box, just remove the if statement and set mvrs = [];
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var mvrs_val = g_form.getValue('multi_row_variable_set_test');
if (mvrs_val == '[]') {
var mvrs = [];
} else {
var mvrs = JSON.parse(mvrs_val);
}
for (var i = 0; i < newValue; i++) {
var tempObj = {};
tempObj.test_report_number = '';
mvrs.push(tempObj);
}
g_form.setValue('multi_row_variable_set_test', JSON.stringify(mvrs));
}
I hope this helps!
If this was helpful or correct, please be kind and remember to click appropriately!
Michael Jones - Proud member of the CloudPires team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 12:44 PM