Mapping Multi-row Variable set to table field using record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2020 08:15 AM
Hello,
Any idea how to map Multi-row Variable set to table field using record producer? please let me know. I have as below and it is not working
current.data=producer.<multi variable set name>;
thanks in advance.
Regards,
Bala

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2020 05:06 AM
When you call producer.<multi variable set name> the return value is a JSON object that contains the variable names and values for the variables in your multi-row variable set, so depending on what type of variable current.data is, your statement may not work.
For example, if you have a multi-row variable set with 3 single-line text fields (var1, var2, var3), and on the form you enter two rows of data when you call producer.<multi variable set name> you would get a return result like this:
[ {
"var1" : "Line 1, Text 1",
"var2" : "Line 1, Text 2",
"var3" : "Line 1, Text 3"
}, {
"var1" : "Line 2, Text 1",
"var2" : "Line 2, Text 2",
"var3" : "Line 2, Text 3"
} ]
So generally you would need to get the return and then parse the object into whatever data you want to populate into a field.
For example, to get all of the values from the above into a pipe separated string, you would use something like this:
var mRow = producer.<multi variable set name>;
var mRowObj = JSON.parse(mRow);
var str = '';
for (i = 0; i < mRowObj.length; i++) {
str += mRowObj[i].var1 + '|' + mRowObj[i].var2 + '|' + mRowObj[i].var3;
if(i != mRowObj.length -1) {
str += '|';
}
}
current.data = str;
Hope that helps.
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2020 11:35 PM
Thank you for the response Jones. I just converted as below and stored
JSON.stringify(g_form.getValue(<>)
thank you
Bala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2020 11:52 PM
Hi Bala,
I have one multi row variable set having two variables.
In record producer script you can try below code, i mapped the variable set values to description field only.
script:
var commentTmp = '';
var contactArr = producer.details;
var contactCnt = producer.details.getRowCount();
if (contactCnt > 0) {
for (i = 0; i < contactCnt; i++) {
commentTmp +="User Data";
commentTmp += "\nFirst Name: "+contactArr[i].first_name+"\nLast Name: "+contactArr[i].last_name +"\n";
}
commentTmp += '';
}
current.description = commentTmp;
Thanks,
Vishal Khandve