How to get variable values from Multirow variable set

YashviPatil
Tera Contributor

Hello,

 

There are two multirow variable sets and i want to retrieve some variables value from one multi row variable set and some are from second multirow variable set. And need to store those two variable set value in json object in one workflow  scratchpad.

 

Thanks,

3 REPLIES 3

Yashsvi
Kilo Sage

Hi @YashviPatil,

please check below link:

https://www.servicenow.com/community/now-platform-forum/how-to-get-values-of-multi-row-variable-set-...

Thank you, please make helpful if you accept the solution.

Omkar Kumbhar
Mega Sage
Mega Sage

 

Hello @YashviPatil ,

Please find the below code modify it according.

 // to get content of mrvs
  var jsonObj = JSON.parse(mrvs);
  var userList = [];
  for (var i=0; i< jsonObj.length; i++) {
    userList.push(jsonObj[i].user_name.toString());   // instead or user_name give your field name from mrvs
  }
  var obj = {};

  obj.multiCategory = userList.join(',').toString();    // storing it in the object and you can call it in workflow
  result.push(obj);
  gs.info(result[0].multiCategory);

Thank you,

Omkar

 

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

newhand
Mega Sage

@YashviPatil 
same sample code.

var gr = new GlideRecord('sc_req_item');
gr.get('04ad95e647528210ea269dbe316d43af');

var mrvs = gr.variables.xxxxxx; //your MRVS name
 
var rowCount = mrvs.getRowCount();
for (var i = 0; i < rowCount; i++) {
    var row = mrvs.getRow(i);
    var xyz = row.ttttt    //your MRV field name
    row.ttttttt = "Dell 17 inch Monitor" + i;   //modify 
	//...
}
Please mark my answer as correct and helpful based on Impact.