Created
July 4, 2021 21:57
-
-
Save mtcoffee/9bac5b0bf1ab8b6a6ed829f929c3be9b to your computer and use it in GitHub Desktop.
mail script to add ServiceNow RITM variables to Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//custom function to retrieve all variables from a RITM and print in email | |
//https://community.servicenow.com/community?id=community_question&sys_id=c8eff1461b4b6050ed6c9979b04bcb59 | |
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template, | |
/* Optional EmailOutbound */ | |
email, /* Optional GlideRecord */ email_action, | |
/* Optional GlideRecord */ | |
event) { | |
// Add your code here | |
template.print("Summary of Requested items:<br />"); | |
var item = new GlideRecord("sc_req_item"); | |
item.addQuery("request", current.sys_id); | |
item.query(); | |
while (item.next()) { | |
template.print("<br />"); | |
template.print(item.number + ": " + item.quantity + " X " + item.cat_item.getDisplayValue() + "<br />"); | |
template.print(" Options:<br />"); | |
var keys = []; | |
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() != '' && vs.get(i).getDisplayValue() != '') { | |
template.space(4); | |
template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "<br />"); | |
} | |
} | |
} | |
})(current, template, email, email_action, event); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment