Email notification with only selected options from select box
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 08:47 AM
Hi,
I have a problem with the email that asks for approval.
Item has 3 Select boxes and depending on the first one, the remaining 2 appear.
I would like the notification to show only what the user has selected, not everything.
How can I achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 10:35 PM
Might be helpful for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 11:33 PM
only here an email script has already been created that iterates through all the variables and puts them in the email if they are not empty.
And with variables that are select boxes, there is never an empty option because even if there is no selection, some option is selected by default
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 10:39 PM
Can you check this-
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 10:46 PM
This script iterates through variables in current, retrieving each variable's label and displayed value using getQuestion() and getDisplayValue(). It checks if the value is filled and prints the label and value formatted if both conditions are met, using template.print() for output.
(function runMailScript(current, template, email, email_action, event) {
// Print header for variables
template.print('Variables: <br/>');
// Retrieve elements (variables/questions) from the current context
var variables = current.variables.getElements();
// Iterate through each variable
for (var i = 0; i < variables.length; i++) {
// Get the question associated with the variable
var question = variables[i].getQuestion();
// Get label (name) of the question
var label = question.getLabel();
// Get displayed value of the question
var value = question.getDisplayValue();
// Check if the value is considered filled
var filled = value != false && value != 'false' && value != undefined && value != '';
// Print label and value if label is not empty and value is filled
if (label != '' && filled) {
template.space(4); // Add indentation
template.print(' ' + label + " = " + value + "<br/>"); // Print label and value
}
}
})(current, template, email, email_action, event);
Might be helpful for you.