Skip to content

Commit 99da281

Browse files
authored
Mail script to print variables to email (#496)
* Create printVarsToMail.js * Update printVarsToMail.js * Create readme.md * Update readme.md
1 parent 810e230 commit 99da281

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
2+
/* Optional EmailOutbound */
3+
email, /* Optional GlideRecord */ email_action,
4+
/* Optional GlideRecord */
5+
event) {
6+
7+
var tableName = current.getDisplayValue('sys_class_name');
8+
9+
template.print("<p></p>" + tableName + ": ");
10+
11+
printVars();
12+
13+
function printVars() {
14+
var varSet = new GlideappVariablePoolQuestionSet();
15+
varSet.setRequestID(current.getValue('sys_id'));
16+
varSet.load();
17+
template.print(current.getDisplayValue('cat_item') + "\n");
18+
template.print("\n");
19+
var variables = varSet.getFlatQuestions();
20+
for (var i = 0; i < variables.size(); i++) {
21+
if (variables.get(i).getLabel() != '') {
22+
if (variables.get(i).getDisplayValue() != '') {
23+
// template.space(6);
24+
template.print(variables.get(i).getLabel() + " : " + variables.get(i).getDisplayValue() + "<br/>");
25+
}
26+
}
27+
}
28+
}
29+
30+
})(current, template, email, email_action, event);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Script block to be used within a Notification Email Script or as a standalone one.
2+
It prints all variables + answers of a catalog produced record to the email body, along with the short description of the task on top (please check script).

0 commit comments

Comments
 (0)