- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2017 03:41 AM
How can I check the variable's variable set in a server side script.
var item = new GlideRecord("sc_req_item");
item.addQuery('sys_id', '1f6d025b13da83008a3efc04e144b0cd'); //I had RITM sysid for testing
item.query();
if(item.next()) {
gs.print(item.number + " : "+ item.cat_item.getDisplayValue());
gs.print(item.stage.getLabel()+" : "+item.stage.getDisplayValue().charAt(0).toUpperCase()+ item.stage.getDisplayValue().slice(1).replaceAll("_"," "));
for (key in item.variables) {
var v = item.variables[key];
var vName = v.getGlideObject().getQuestion().getName(); //I got the name of the fields
var vLabel = v.getGlideObject().getQuestion().getLabel(); // I got the label of the fields
var vRecord = v.getGlideObject().getRefRecord(); //but I can't get the variable set name of the fields
if(arrayUtil.contains(arr, vName)) { //ignore this condition, I have a definite list of variables that I'm checking
gs.print(' ' + vName + ' - ' + vLabel + " = " + v.getDisplayValue() + ' - ' + vRecord.getValue('variable_set'));
}
}
}
Please help, thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2017 05:53 AM
Hey try this inside for loop
var gr = new GlideRecord('sc_item_option_mtom')
gr.addQuery('request_item', item.sys_id);
gr.addQuery('sc_item_option.item_option_new.name', vName );
gr.query();
if(gr.next())
gs.print(gr.sc_item_option.item_option_new.variable_set.name)
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2017 05:53 AM
Hey try this inside for loop
var gr = new GlideRecord('sc_item_option_mtom')
gr.addQuery('request_item', item.sys_id);
gr.addQuery('sc_item_option.item_option_new.name', vName );
gr.query();
if(gr.next())
gs.print(gr.sc_item_option.item_option_new.variable_set.name)
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2017 01:01 AM
Yeah I thought about this, but I'm hesitant to use it because I reckon the execution time of the script will be long with a gliderecord on every variable. This is a correct solution though so I'll mark this as correct answer. Thank you for the reply.