- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2020 11:38 AM
Does anyone have any examples they can share of presenting RITM variable summary in an email notification script in a table format?
We have approvals triggered from Requested Items and are currently providing the OOTB script summary but i would like to format those results into a table format like this:
Variable 1 | Answer 1 |
Variable 2 | Answer 2 |
Variable 3 | Answer 3 |
Variable 4 | Answer 4 |
Variable 5 | Answer 4 |
template.print("Summary of Requested items:\n");
var item = new GlideRecord("sc_req_item");
item.addQuery("request", current.sysapproval);
item.query();
while(item.next()) {
template.print(item.number + ": " + item.quantity + " X " + item.cat_item.getDisplayValue() + " at " + item.price.getDisplayValue() + " each \n");
template.print(" Options:\n");
var keys = new Array();
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(item.sys_id);
set.load();
var vs = set.getFlatQuestions();
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getLabel() != '') {
template.space(4);
template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n");
}
}
}
Solved! Go to Solution.
- Labels:
-
Content Management
-
Notifications

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2020 11:57 AM
Hi,
you need to wrap the variables in HTML table formatting as below. I've not condensed the HTML so you can visually see the formatting.
template.print("Summary of Requested items:\n");
var item = new GlideRecord("sc_req_item");
item.addQuery("request", current.sysapproval);
item.query();
while(item.next()) {
template.print(item.number + ": " + item.quantity + " X " + item.cat_item.getDisplayValue() + " at " + item.price.getDisplayValue() + " each \n");
template.print(" Options:\n");
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(req.sys_id);
set.load();
var vs = set.getFlatQuestions();
template.print("<table><tbody>");
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getLabel() != '') {
template.print("<tr>");
template.print("<td>");
template.print(vs.get(i).getLabel());
template.print("</td>");
template.print("<td>");
template.print(vs.get(i).getDisplayValue());
template.print("</td>");
template.print("<tr>");
}
}
template.print("</table></tbody>");
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2020 11:57 AM
Hi,
you need to wrap the variables in HTML table formatting as below. I've not condensed the HTML so you can visually see the formatting.
template.print("Summary of Requested items:\n");
var item = new GlideRecord("sc_req_item");
item.addQuery("request", current.sysapproval);
item.query();
while(item.next()) {
template.print(item.number + ": " + item.quantity + " X " + item.cat_item.getDisplayValue() + " at " + item.price.getDisplayValue() + " each \n");
template.print(" Options:\n");
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(req.sys_id);
set.load();
var vs = set.getFlatQuestions();
template.print("<table><tbody>");
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getLabel() != '') {
template.print("<tr>");
template.print("<td>");
template.print(vs.get(i).getLabel());
template.print("</td>");
template.print("<td>");
template.print(vs.get(i).getDisplayValue());
template.print("</td>");
template.print("<tr>");
}
}
template.print("</table></tbody>");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2020 01:05 PM
thanks that worked great!