- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 01:38 AM
How can I access a particular field value of a Multi Row variable set to a workflow?
I need the value of Level in workflow to trigger approval.. I tried below but its returning undefined:
answer = ifScript();
var mrvs = current.variables.Grants;//replace with the internal name of your MRVS
var mrs = g_form.variables.Grants;
workflow.info('mrs'+mrs);
workflow.info('mrvs'+mrvs);
function ifScript()
{
var rowCount = mrvs.getRowCount();
for(var i=0;i<rowCount; i++){//for each row in the MRVS
var row = mrvs.getRow(i);
workflow.info('row'+row);
workflow.info('row.level'+row.level);
if(row.level == 'Project')
{
return 'yes';
}
else
{
return 'no';
}
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 06:35 AM
Leveraging the Array.some method makes this much cleaner
answer = (function ifScript() {
return JSON.parse(current.variables.Grants)
.some(function(row){
return row.level === "Project";
}) ? "yes": "no";
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 02:50 AM
hey can you try this
and i hope Grants is the internal name of the MVRS and not the actual name.Please double check that
ifScript();
function ifScript()
{
if(JSON.parse(current.variables.Grants)!='')
{
var str = JSON.stringify(current.variables.Grants);
var mrvs = JSON.parse(str);
for(var i=0;i<mrvs.length; i++){//for each row in the MRVS
if(mrvs[i].level == 'Project')
{
return 'yes';
}
else
{
return 'no';
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 03:07 AM
Try the below code snippet
answer = ifScript();
function ifScript() {
var mrvs = current.variables.Grants; //replace with the internal name of your MRVS
var isPrjLevel = "no";
var rowCount = mrvs.getRowCount();
gs.info('No of grants added ' + rowCount);
for (var i = 0; i < rowCount; i++) { //for each row in the MRVS
var level = mrvs.getRow(i).level;
gs.info('Grant level is ' + level);
if (level == 'Project') {
isPrjLevel = 'yes';
break;
} else {
return 'no';
}
}
return isPrjLevel;
}
Thanks & Regards,
Vasanth