Need help on getting Variable name from MRVS

shaik_irfan
Tera Guru

Hi,

I have a MRVS when i called that i get the variable values in JSON format but i get the backend variable name not Question

 

How to get the question and instead of variable name

 

in the catalog client script if i try using 

alert(g_form.getValue('mrvs_name'));

 

In server side

gs.info(current.variables.mrvs_name); //from workflow 

 

I get the same output in JSON format

 

 

 

Can anyone please help me how to display the questions ?

Hitoshi Ozawa
Giga Sage

The easiest to to just use the same name as the question but sometimes this is not possbile.

Questions and variables are in sc_item_option table. Query on the 'value' to find the 'question'.

@hozawa 

 

Can we atleast hard code the questions in scripting like user with User, test2 with Test Application something like that 

@shaik.irfan 

this should help

it would print the key and the value

var obj = [ {
"user" : "b326ee822f1f8890209857892799b6b3",
"test2" : "asdf",
"test" : "asfd"
} ];

var parser = JSON.parse(JSON.stringify(obj));

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

var obj = parser[i];

for(var key in obj){

gs.info('Key is' + key);
gs.info('Value is' + obj[key]);

}

}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi,

if you want to print the Question Label and the value for that then use this

MRVS data is stored in this table "sc_multi_row_question_answer"

sample script:

var gr = new GlideRecord('sc_multi_row_question_answer');

gr.addQuery('parent_id', current.sys_id);

gr.query();

while(gr.next()){

gs.info('Question label ' + gr.item_option_new.getDisplayValue());

gs.info('Value is ' + gr.value);

}

Output:

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader