The CreatorCon Call for Content is officially open! Get started here.

how to retrieve multi row variable set in servicenow

sony8
Tera Contributor

Hi everyone,

 

i am facing issue with below scenario:

there is multi row variable set as below

selection is name of multi row variable set

variables are Ac Number and No of AC

there is a table in native UI AC Storage table(ac_storage_table)

when i submit the below request from portal by selecting 3 different values of AC numbers it should create 3 different requests in ac_storage table .

 

i have written below script in Record producer, but not working 

for (var i =0; i < arr.length; i++){

var gr= new GlideRecord('ac_storage_table');
gr.initialize();
gr.ac_number = current.ac_number;
gr.no_of_ac = current.no_of_ac ;
gr.number = current.number;
gr.assigned_to = current.assigned_to;
gr.insert();

}
 
 
how to filter values from multi row variable set?
 
any one has idea please help me..
 
thanks in advance
2 REPLIES 2

Ben_G
Tera Expert

Since you have a for loop already with an array, I assume you're storing the MRVS in there?

 

In the for loop, instead of current.ac_number it should be something like arr[i].ac_number. You need to access the item in the array first, and then the property. A MRVS will be stored like below where each item in the array is a row in the MRVS.

 

[
{
 "variable1" : "value",
 "variable2" : "value",
},
{
 "variable1" : "value",
 "variable2" : "value",
}
]

 



This is just a guess without seeing the structure of the MRVS or the rest of your code.

When I am working on something like this, I like to log what I am doing either into the system logs or throwing it into a info message.

See here for more info Creating records or a summary from Multi-Row Variable Set 

sony8
Tera Contributor
  1. No I am not storing mrvs . As I am using Multi row variable set for first time I don't have idea regarding it , could you please share me sample code I will do it accordingly ??? 

Thank you.