- 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 04:28 PM
Hi Jim,
Please refer below link and adjust your code. Let me know if you are blocked.
Showing Request Item / Catalog Variables in Mail Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2016 04:48 PM
Hi Pradeep,
Not sure which part to adjust.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2016 05:08 PM
I also need each variable to print onto a new line in the email, at the moment everything is:
Catering Request Details Requestor: bebc31ea4f9016007c249dde0310c7c8 Requestor email:example@example.com Authorised By: bebc31ea4f9016007c249dde0310c7d8Authorised by email: email:example@example.com Contact Number: 123 Date Required:2016-07-19 Purpose: test Start Time: 9:00 AM End Time: 2:00 PM Region:2bd7bebf4f8092007c249dde0310c773 Location: d902eb6fdb4ca20095b9dd1dbf9619be Team:8d04eb23db8ca20095b9dd1dbf96198c Charge Code: af177767db8ca20095b9dd1dbf96193fPlease Specify: toasted_muesli Layout: original
Any ideas how to achieve this?

- 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/>");
}
}