- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2018 12:47 PM
I am attempting to pass Service Catalog variables from one RITM to another (via ebonding), however, one of the Packages that I was using to accomplish this, GlideappAbstractChoiceListQuestion, is not available within a scoped application. Does anyone know an alternative?
Essentially, I am pulling data from the sc_item_option_mtom table, which is working, but if the data returned is referenced from another table (sys_user, cmn_location, etc) it is only showing the Sys_ID, instead of a friendly Display Value.
Below is an example of a simple script that can be run in Scripts - Background. This WILL work in Global Scope, but I get: "Error: GlideappAbstractChoiceListQuestion is not allowed in scoped applications" if run in my scope.
var varown = new GlideRecord('sc_item_option_mtom');
varown.addQuery("request_item", 'SYS_ID HERE');
varown.addQuery("sc_item_option.item_option_new.type","NOT IN","12,20,24,19");
varown.orderBy("sc_item_option.order");
varown.query();
while (varown.next()){
var visible = varown.sc_item_option.item_option_new.visible_summary;
var question = GlideappAbstractChoiceListQuestion.getQuestion(varown.sc_item_option.item_option_new);
question.setValue(varown.sc_item_option.value);
if(question.getDisplayValue() != ""){
gs.print('Question:'+question.getLabel());
gs.print('Variable Name:'+question.name);
gs.print('Value:'+question.getDisplayValue() + '\n\n');
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2018 11:40 AM
One more correction
var item = new GlideRecord('sc_req_item');
item.addQuery('number','RITM0010001');
item.query();
if (item.next())
{
gs.info(item.number);
var varown = new GlideRecord('sc_item_option_mtom');
varown.addQuery('request_item', item.sys_id+'');
//varown.addQuery("sc_item_option.item_option_new.type","NOT IN","12,20,24,19");
varown.orderBy("sc_item_option.order");
varown.query();
while (varown.next())
{
//gs.info(varown.sc_item_option.item_option_new);
var visible = varown.sc_item_option.item_option_new.visible_summary;
if(varown.sc_item_option.item_option_new.getDisplayValue() != "" && typeof item.variables[varown.sc_item_option.item_option_new.name]!='undefined')
{ gs.info('Question:'+varown.sc_item_option.item_option_new.getDisplayValue()+' : '+item.variables[varown.sc_item_option.item_option_new.name].getDisplayValue());
}
}
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2018 07:42 AM
I am still getting sys_id's instead of a friendly value for certain fields: see below. I have always been able to get this information. I've been trying to get the friendly display value for all of the reference fields.
x_sotd2_ebond: Question:Department : 470f37cbdbb2c3003e8974821f9619b3
x_sotd2_ebond: Question:Requested For : e05408d3dbf2c3003e8974821f9619f1
x_sotd2_ebond: Question:Requested by : e05408d3dbf2c3003e8974821f9619f1
x_sotd2_ebond: Question:Phone Number : 333-333-3333
x_sotd2_ebond: Question:Request Information : undefined
x_sotd2_ebond: Question:Request Type : add_owner
x_sotd2_ebond: Question:Distribution Group Name : test
x_sotd2_ebond: Question:Select Group Owner(s) to Add : eeb326c5dbd01b085309f4821f9619c4,ffd48347db32c3003e8974821f96197a
x_sotd2_ebond: Question:Business Justification : test
x_sotd2_ebond: Question:Addtional Comments :

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2018 10:23 AM
Ok. One last try
var item = new GlideRecord('sc_req_item');
item.addQuery('number','RITM0010001');
item.query();
if (item.next())
{
gs.info(item.number);
var varown = new GlideRecord('sc_item_option_mtom');
varown.addQuery('request_item', item.sys_id+'');
//varown.addQuery("sc_item_option.item_option_new.type","NOT IN","12,20,24,19");
varown.orderBy("sc_item_option.order");
varown.query();
while (varown.next())
{
//gs.info(varown.sc_item_option.item_option_new);
var visible = varown.sc_item_option.item_option_new.visible_summary;
if(varown.sc_item_option.item_option_new.getDisplayValue() != "")
{ gs.info('Question:'+varown.sc_item_option.item_option_new.getDisplayValue()+' : '+item.variables[varown.sc_item_option.item_option_new.name].getDisplayValue());
}
}
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2018 10:34 AM
This is close. It is now pulling some of the values, but I'm receiving the following error partway through:
x_sotd2_ebond: Question:Department : TheDepartmentName
x_sotd2_ebond: Question:Requested For : Example User (QWE123)
x_sotd2_ebond: Question:Requested by : Example User2 (ASD123)
x_sotd2_ebond: Question:Preferred Contact : Requested For
x_sotd2_ebond: Question:Preferred Contact Method : Phone
x_sotd2_ebond: Question:Phone Number : 333-333-3333
Evaluator: org.mozilla.javascript.EcmaError: The undefined value has no properties. Caused by error in script at line 17 14: //gs.info(varown.sc_item_option.item_option_new); 15: var visible = varown.sc_item_option.item_option_new.visible_summary; 16: if(varown.sc_item_option.item_option_new.getDisplayValue() != "") ==> 17: { gs.info('Question:'+varown.sc_item_option.item_option_new.getDisplayValue()+' : '+item.variables[varown.sc_item_option.item_option_new.name].getDisplayValue()); 18: } 19: } 20: }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2018 11:22 AM
Ok...Added one more condition
var item = new GlideRecord('sc_req_item');
item.addQuery('number','RITM0010001');
item.query();
if (item.next())
{
gs.info(item.number);
var varown = new GlideRecord('sc_item_option_mtom');
varown.addQuery('request_item', item.sys_id+'');
//varown.addQuery("sc_item_option.item_option_new.type","NOT IN","12,20,24,19");
varown.orderBy("sc_item_option.order");
varown.query();
while (varown.next())
{
//gs.info(varown.sc_item_option.item_option_new);
var visible = varown.sc_item_option.item_option_new.visible_summary;
if(varown.sc_item_option.item_option_new.getDisplayValue() != "" && typeofitem.variables[varown.sc_item_option.item_option_new.name]!='undefined')
{ gs.info('Question:'+varown.sc_item_option.item_option_new.getDisplayValue()+' : '+item.variables[varown.sc_item_option.item_option_new.name].getDisplayValue());
}
}
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2018 11:35 AM
Evaluator: org.mozilla.javascript.EcmaError: "typeofitem" is not defined. Caused by error in script at line 18 15: { 16: //gs.info(varown.sc_item_option.item_option_new); 17: var visible = varown.sc_item_option.item_option_new.visible_summary; ==> 18: if(varown.sc_item_option.item_option_new.getDisplayValue() != "" && typeofitem.variables[varown.sc_item_option.item_option_new.name]!='undefined') 19: { gs.info('Question:'+varown.sc_item_option.item_option_new.getDisplayValue()+' : '+item.variables[varown.sc_item_option.item_option_new.name].getDisplayValue()); 20: } 21: }