- 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
09-09-2019 02:09 PM
Try using "<br/>" as opposed to "\n\n" in your mail_script.
ServiceNow appears to prefer the HTML line break over the JS line break.