OBJ.length returning null for Multi row variable set

Community Alums
Not applicable

Hi folks,

I want to retreive manager sys ID from MRV set,

MRV set is returning list of records as OBJ, when i try ulist.length it's throwing null.

Is there any other way to retreive values from MRV set ?

 

var gr= new GlideRecord('sc_req_item');
gr.addQuery('sys_id','a21b171297a5021051673e2e6253af8f');
gr.query();
var i;
if(gr.next()){
	gs.info('hello');
	var val= gr.variables.select_the_group;

	var ulist= gr.variables.select_users;//retreiving values from MRV.


gs.info(val);
	
gs.info(ulist);
gs.info(ulist.length);
}

Output:

 

KhasimPathan_0-1713778917455.png

 

1 ACCEPTED SOLUTION

James Chun
Kilo Patron

Hi @Community Alums,

 

You can either use a Flow to iterate through the values of an MRVS or use the following script:

 

var mrvs = current.variables.your_mrvs_name;
var rowCount = mrvs.getRowCount();
//loop through the MRVS contents
for (var i = 0; i < rowCount; i++) {
    var row = mrvs.getRow(i);
    gs.info(row.variable_name_mrvs);
}

 

Source - https://www.servicenow.com/community/developer-forum/help-looping-thru-mrvs-in-workflow-script/m-p/2799236

https://www.servicenow.com/community/now-platform-forum/how-do-i-iterate-through-a-multi-row-variable-set-in-flow/m-p/1106790

 

Cheers

View solution in original post

1 REPLY 1

James Chun
Kilo Patron

Hi @Community Alums,

 

You can either use a Flow to iterate through the values of an MRVS or use the following script:

 

var mrvs = current.variables.your_mrvs_name;
var rowCount = mrvs.getRowCount();
//loop through the MRVS contents
for (var i = 0; i < rowCount; i++) {
    var row = mrvs.getRow(i);
    gs.info(row.variable_name_mrvs);
}

 

Source - https://www.servicenow.com/community/developer-forum/help-looping-thru-mrvs-in-workflow-script/m-p/2799236

https://www.servicenow.com/community/now-platform-forum/how-do-i-iterate-through-a-multi-row-variable-set-in-flow/m-p/1106790

 

Cheers