- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2016 03:32 PM
Hi all,
I'm using this mail script to capture variables for a catalog item to be sent in a notification:
printVars();
function printVars() {
template.print('<b>Catering Request Details</b>\n');
var cv = new GlideRecord('sc_item_option_mtom');
cv.addQuery('request_item', current.sys_id);
cv.addNotNullQuery('sc_item_option.value');
cv.orderBy('sc_item_option.order');
cv.addQuery('sc_item_option.value', '!=', '0');
cv.addQuery('sc_item_option.value', '!=',"false");
cv.query();
while(cv.next()) {
template.print('\n' + cv.sc_item_option.item_option_new.question_text + ':\t<b>' + cv.sc_item_option.value + '</b>');
}
}
I have a few variables that are type Reference and for these the sys_id is returned. I think need to include a getDisaplayValue condition in the script but not sure where to put, of if that is even the correct approach. Any ideas anyone?
Thanks,
Jimmy
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2016 05:52 PM
Here you go
template.print('<b>Catering Request Details</b>'+ "<br/>");
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.sys_id.toString());
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getLabel() != '' && vs.get(i).getDisplayValue()!='' && vs.get(i).getDisplayValue()!='false') {
template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "<br/>");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2016 08:00 PM
Abhinay,
You are a legend my friend!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2016 08:09 PM
Hi Jim,
I just saw your response.
Sorry for being late on this one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2016 02:00 PM
No worries, Pradeep. Thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2017 08:57 AM
You can write a mail script :
var dm = current.sys_domain;
var val = current.state;
var myLabel = Choice(dm,"state",val);
template.print("<strong>State:</strong> "+myLabel);
function Choice(a,b,c){
var query = 'sys_domain='+a+'^element='+b+'^value='+c;
var gr = new GlideRecord("sys_choice");
gr.addEncodedQuery(query);
gr.query();
if (gr.next()) return gr.label;
}