Created
July 4, 2021 22:02
-
-
Save mtcoffee/b469f6cd16b6c50cb600cee661431ee9 to your computer and use it in GitHub Desktop.
mail script to add ServiceNow RITM variables to Task
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 Related Requested item:<br />"); | |
var item = new GlideRecord("sc_req_item"); | |
item.addQuery("sys_id", current.request_item); //this line matters if changing from REQ/RITM/SC_TASK | |
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