- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 06:54 AM
Hello All!
I'm working on an email script to display request information (not for an approval) and I'm struggling to get the information to display in a readable manner. Below is the script I have managed to piece together to display variables from the request and exclude any variables that are false or have no value.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 08:27 AM
Hi @James Turney ,
Please try with below updated code, html <table> tag added before and after while loop.
If this update not work for you then add boarder attribute with <table boarder=1> and check the output.
function printVars() {
template.print("<b>Summary of Requested Item</b>:\n");
var requesterName;
//var gr = new GlideRecord("sc_req_item");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sys_id);
gr.query();
//template.print("Details:\n");
var itemOptions = new GlideRecord('sc_item_option_mtom');
itemOptions.addQuery('request_item', current.sys_id);
itemOptions.orderBy('sc_item_option.order');
itemOptions.query();
// template.print('<table bgcolor="#D9E3C1" border="0" cellspacing="2">');
template.print('<table>')
while (itemOptions.next()) {
var visible = itemOptions.sc_item_option.item_option_new.visible_summary;
var question = GlideappAbstractChoiceListQuestion.getQuestion(itemOptions.sc_item_option.item_option_new);
question.setValue(itemOptions.sc_item_option.value);
if (visible == true && question.getLabel() != '' && question.getLabel() != null && question.getDisplayValue() != '' && question.getDisplayValue() != 'false') {
template.print('<tr><th align="left" width="15%">' + "<span style='color:#151B54'>" + question.getLabel() + ":" + '</th></span><td>' + "<span style='color:#151B54'>" + question.getDisplayValue() + '</td></span></tr>\n');
if (question.getLabel() == 'Name') {
requesterName = question.getDisplayValue();
}
}
}
template.print('</table>');
}
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 08:27 AM
Hi @James Turney ,
Please try with below updated code, html <table> tag added before and after while loop.
If this update not work for you then add boarder attribute with <table boarder=1> and check the output.
function printVars() {
template.print("<b>Summary of Requested Item</b>:\n");
var requesterName;
//var gr = new GlideRecord("sc_req_item");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sys_id);
gr.query();
//template.print("Details:\n");
var itemOptions = new GlideRecord('sc_item_option_mtom');
itemOptions.addQuery('request_item', current.sys_id);
itemOptions.orderBy('sc_item_option.order');
itemOptions.query();
// template.print('<table bgcolor="#D9E3C1" border="0" cellspacing="2">');
template.print('<table>')
while (itemOptions.next()) {
var visible = itemOptions.sc_item_option.item_option_new.visible_summary;
var question = GlideappAbstractChoiceListQuestion.getQuestion(itemOptions.sc_item_option.item_option_new);
question.setValue(itemOptions.sc_item_option.value);
if (visible == true && question.getLabel() != '' && question.getLabel() != null && question.getDisplayValue() != '' && question.getDisplayValue() != 'false') {
template.print('<tr><th align="left" width="15%">' + "<span style='color:#151B54'>" + question.getLabel() + ":" + '</th></span><td>' + "<span style='color:#151B54'>" + question.getDisplayValue() + '</td></span></tr>\n');
if (question.getLabel() == 'Name') {
requesterName = question.getDisplayValue();
}
}
}
template.print('</table>');
}
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution