- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 12:37 PM
We have an e-mail notification that goes out to users when their ticket is created. There is a mail script that is used to list all the variables in the ticket. How can I modify this script to ONLY display variables that are not empty? We are doing some mapping and it listing empty variables is causing issues. Here is the current script being used:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 12:51 PM
Hi @Brent Cox : Have you tried using below script ?
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('Variable Summary: <br/>');
var variables = current.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 != '' && value != ''){
template.space(4);
template.print(' ' + label + " = " + value + "<br/>");
}
}
})(current, template, email, email_action, event);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 12:51 PM
Hi @Brent Cox : Have you tried using below script ?
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('Variable Summary: <br/>');
var variables = current.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 != '' && value != ''){
template.space(4);
template.print(' ' + label + " = " + value + "<br/>");
}
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 01:50 PM
I think this is exactly what I am needing. Thank you so much!