- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2014 04:11 AM
Where the data were stored for Request Item catalog variables?
I want to fetch all the variables of request item in a single field by comma separated .
Thanks,
Solved! Go to Solution.
- Labels:
-
Service Mapping
- 44,906 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2014 04:31 AM
Hi,
If you want to access all variable related to any request item use following Script.
var item = new GlideRecord("sc_req_item");
item.addQuery("request", requestSys_id);
item.query();
if (item.next()) {
// grab all variable sets from the parent request
var var_own = new GlideRecord('sc_item_option_mtom');
var_own.addQuery('request_item', item.sys_id);
//var_own.addQuery('sc_item_option.item_option_new.u_approval_display', 'global');
var_own.orderBy('sc_item_option.item_option_new.order');
var_own.query();
while (var_own.next()){
gs.print(var_own.sc_item_option.item_option_new.question_text + ": " + eval('item.variable_pool.'+var_own.sc_item_option.item_option_new.name+'.getDisplayValue()') + "\n");
}
}
Thanks,
Sanjeev Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2014 04:26 AM
Hi ,
Check flollowing table.
sc_item_option_mtom
Thanks,
Sanjeev kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2014 04:31 AM
Hi,
If you want to access all variable related to any request item use following Script.
var item = new GlideRecord("sc_req_item");
item.addQuery("request", requestSys_id);
item.query();
if (item.next()) {
// grab all variable sets from the parent request
var var_own = new GlideRecord('sc_item_option_mtom');
var_own.addQuery('request_item', item.sys_id);
//var_own.addQuery('sc_item_option.item_option_new.u_approval_display', 'global');
var_own.orderBy('sc_item_option.item_option_new.order');
var_own.query();
while (var_own.next()){
gs.print(var_own.sc_item_option.item_option_new.question_text + ": " + eval('item.variable_pool.'+var_own.sc_item_option.item_option_new.name+'.getDisplayValue()') + "\n");
}
}
Thanks,
Sanjeev Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2018 08:23 AM
Your post was very helpful as getGlideObject is not available in scoped application. The one thing I have changed in my code has been to eliminate the 'eval' as it is generally considered to be dangerous.
gs.print(var_own.sc_item_option.item_option_new.question_text + ": " + eval('item.variable_pool.'+var_own.sc_item_option.item_option_new.name+'.getDisplayValue()') + "\n");
replacing with:
gs.print(var_own.sc_item_option.item_option_new.question_text + ": " + item.variable_pool[var_own.sc_item_option.item_option_new.name].getDisplayValue() + "\n");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2018 09:34 AM
My updated method derived from what SK shared...
_getVariables: function(record){
// 'Variable Ownership'(sc_item_option_mtom) => var_own
// *request_item = ref Request Item(sc_req_item)
// *sc_item_option = ref Options(sc_item_option)
// *Value(value)
// *Question(item_option_new) = ref Variable (item_option_new)
// *Variable Set(variable_set)
// *Type(type)
// *Order(order)
// *Question(question_text)
// *Name(name)
// grab all variable sets from the parent request
var var_own = new GlideRecord('sc_item_option_mtom');
var_own.addQuery('request_item', record.sys_id);
//variable is active, not of type break(12), Container Start(19),Container End(20), Container Split(24) and value is not null
var_own.addEncodedQuery('sc_item_option.item_option_new.active=true^sc_item_option.item_option_new.typeNOT IN12,19,20,24^sc_item_option.value!=NULL');
var_own.orderBy('sc_item_option.item_option_new.order');
var_own.query();
var arrVars = [];
while (var_own.next()) {
objVar = {
variable_set: {
},
type:{
}
};
objVar.type.value = var_own.sc_item_option.item_option_new.type.toString();
objVar.type.display_value = var_own.sc_item_option.item_option_new.type.getDisplayValue();
objVar.ref = var_own.sc_item_option.item_option_new.reference.toString();
objVar.variable_set.value = var_own.sc_item_option.item_option_new.variable_set.toString();
objVar.variable_set.display_value = var_own.sc_item_option.item_option_new.variable_set.getDisplayValue();
objVar.order = var_own.sc_item_option.item_option_new.order.toString();
objVar.question = var_own.sc_item_option.item_option_new.question_text.toString();
objVar.name = var_own.sc_item_option.item_option_new.name.toString();
objVar.value = var_own.sc_item_option.value.toString();
objVar.display_value = record.variable_pool[var_own.sc_item_option.item_option_new.name].getDisplayValue();
arrVars.push(objVar);
}
return arrVars;
},