- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 04:46 AM
Hi All,
I have written an onSubmit code to get the number of rows inserted into MVRS (multi-row variable set).
var mvrsValue = g_form.getValue('questions');
if(mvrsValue){//if it has a value
var jsonObj = JSON.parse(mvrsValue);
console.log('There are ' + jsonObj.length + ' rows); }
else { // if i recall correctly, .getValue returns null if empty
console.log('No Rows'); }
When I run this I get
[{
"order": "100",
"question": "What do you need help with?",
"required": "Yes",
"help_text": "test"
}]
Now I want to get the value from this.
For example--
What is the value of order and required
Thanks,
Piyush Kumar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 05:02 AM
Hi @Piyush27
Try the following code.
function onSubmit() {
//Type appropriate comment here, and begin script below
var mvrsValue = g_form.getValue('questions');
if (mvrsValue) {
var jsonObj = JSON.parse(mvrsValue);
for(key in jsonObj){
console.log('Order: ' + jsonObj[key].order + ', Required: ' + jsonObj[key].required);
}
console.log('There are ' + jsonObj.length + ' rows');
} else { // if i recall correctly, .getValue returns null if empty
console.log('No Rows');
}
}
Please mark my answer helpful and accept as solution if it helped you 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 05:02 AM
Hi @Piyush27
Try the following code.
function onSubmit() {
//Type appropriate comment here, and begin script below
var mvrsValue = g_form.getValue('questions');
if (mvrsValue) {
var jsonObj = JSON.parse(mvrsValue);
for(key in jsonObj){
console.log('Order: ' + jsonObj[key].order + ', Required: ' + jsonObj[key].required);
}
console.log('There are ' + jsonObj.length + ' rows');
} else { // if i recall correctly, .getValue returns null if empty
console.log('No Rows');
}
}
Please mark my answer helpful and accept as solution if it helped you 👍✔️
Anvesh