- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 12:57 AM
Morning all
I have seen there are lots of posts regarding the displaying of Variables in an email notification. I have come across this one:-
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 11:51 PM
Morning Avocado,
Thank you for the reply. I actually figured it out last night and it is simply as easy as changing
if(label != ''){
to this
if(value!= ''&& value!= 'false'){
Another example of overthinking things!. It works perfectly now. Here is the full script, with improved formatting if anyone else wishes to use it :-
// Add your code here
template.print('<b>Full Details:-</b> <br/><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(value!= ''&& value!= 'false'){
template.space(4);
template.print('<b> ' + label + '</b>' + " = " + value + "<br/><br/>");
}
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 09:47 AM
Try adding another condition for your if statement:
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('Full Details:- <br/>');
var variables = current.variables.getElements();
var question,
value;
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
09-17-2024 11:51 PM
Morning Avocado,
Thank you for the reply. I actually figured it out last night and it is simply as easy as changing
if(label != ''){
to this
if(value!= ''&& value!= 'false'){
Another example of overthinking things!. It works perfectly now. Here is the full script, with improved formatting if anyone else wishes to use it :-
// Add your code here
template.print('<b>Full Details:-</b> <br/><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(value!= ''&& value!= 'false'){
template.space(4);
template.print('<b> ' + label + '</b>' + " = " + value + "<br/><br/>");
}
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 01:49 PM
Could this be run on an email script for a notification on the sc_request table?