- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 07:19 AM
this is what i have, but it only prints the variables in the preview notification. not the request item the email is pertaining to.
var gr = new GlideRecord("sc_req_item");
gr.addQuery(current);
gr.query();
if(gr.next()) {
template.print(gr.cat_item.getDisplayValue() + "\n");
template.print("\n");
for (key in gr.variables) {
var v = gr.variables[key];
if(v.getGlideObject().getQuestion().getLabel() != '') {
if(v.getDisplayValue() != ""){
template.space(6);
template.print(' ' + v.getGlideObject().getQuestion().getLabel() + " : " + v.getDisplayValue() + "\n");
}
}
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 07:27 AM
Hi Ryan,
This code snippet is intended to run on approval records. Change the current.getValue('sysapproval') part to point to the right record sys_id as needed.
printVars();
function printVars(){
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.getValue('sysapproval'));
set.load();
var vs = set.getFlatQuestions();
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getLabel() != '') {
template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n");
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 07:27 AM
Hi Ryan,
This code snippet is intended to run on approval records. Change the current.getValue('sysapproval') part to point to the right record sys_id as needed.
printVars();
function printVars(){
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.getValue('sysapproval'));
set.load();
var vs = set.getFlatQuestions();
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getLabel() != '') {
template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n");
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 12:22 PM
Hey Chuck, I saw that one in another post, I'm running the notification on the sc_req_item table, When i try using that and replace sysapproval with current.request
or something alike, it doesn't display anything. I'm not quite sure the best way go about that part.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 06:49 PM
If you are running the notification sc_req_item and the variables are on that record, then use current.getValue('sys_id')
current.getValue('request') returns the sys_id of the parent request. That's why it didn't return anything - no variables there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2016 07:45 AM
Thank you so much, it worked! This is end result script:
template.print("<p></p>Requested item: ");
printVars();
function printVars(){
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.getValue('sys_id'));
set.load();
template.print(current.getDisplayValue('cat_item') + "\n");
template.print("\n");
var vs = set.getFlatQuestions();
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getLabel() != '') {
if (vs.get(i).getDisplayValue() != ''){
template.space(6);
template.print(' ' + vs.get(i).getLabel() + " : " + vs.get(i).getDisplayValue() + "\n");
}
}
}
}