- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2022 03:42 AM
I'm having an issue on printing Catalog Questions/Variables on a RITM Email Notification? I was able to create a Mail Script with the script below to print on REQ email notifications but with this script nothing prints for a RITM email notification.
==============SCRIPT================
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
template.print("<p style='font-family:Helvetica;font-size:12pt'>Summary of Requested Items<br>");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while (gr.next()) {
var reqItemVars = gr.variables.getElements();
for (var variable = 0; variable < reqItemVars.length; variable++) {
var question = reqItemVars[variable].getQuestion();
template.space(4);
template.print(question.getLabel() + ": " + question.getDisplayValue() + "<br>");
}
template.print("<br>");
}
template.print("</p>");
})(current, template, email, email_action, event);
==============END SCRIPT================
Thanks,
AJ
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2022 03:51 AM
Hi,
Use below script for RITM
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
template.print("<p style='font-family:Helvetica;font-size:12pt'>Summary of Requested Items<br>");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sys_id);
gr.query();
while (gr.next()) {
var reqItemVars = gr.variables.getElements();
for (var variable = 0; variable < reqItemVars.length; variable++) {
var question = reqItemVars[variable].getQuestion();
template.space(4);
template.print(question.getLabel() + ": " + question.getDisplayValue() + "<br>");
}
template.print("<br>");
}
template.print("</p>");
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2022 03:51 AM
Hi,
Use below script for RITM
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
template.print("<p style='font-family:Helvetica;font-size:12pt'>Summary of Requested Items<br>");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sys_id);
gr.query();
while (gr.next()) {
var reqItemVars = gr.variables.getElements();
for (var variable = 0; variable < reqItemVars.length; variable++) {
var question = reqItemVars[variable].getQuestion();
template.space(4);
template.print(question.getLabel() + ": " + question.getDisplayValue() + "<br>");
}
template.print("<br>");
}
template.print("</p>");
})(current, template, email, email_action, event);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2022 03:52 AM
Hi,
Try below script and let me know.
(function runMailScript(current, template, email, email_action, event) {
//Get the Catalog Variables
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id', current.sysapproval);
ritm.query();
if (ritm.next()) {
var fname, lname;
var variables = ritm.variables.getElements();
for (var i = 0; i < variables.length; i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if (label != '') {
if (label == 'First Name') { //Your calalog field name
fname = value;
} else if (label == 'Last Name') {
lname = value;
}
}
}
}
})(current, template, email, email_action, event);
Mark this as Helpful/Correct, if Applicable.
Regards,
Sourabh