
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2024 05:55 PM
So I am creating a mail notification that is generated from a RITM, it has some standard text, some variable values and that is all working fine.
The part I'm having issues with is where our users have chosen yes or no to a list of questions - I want to show all the questions they have answered yes to.
Please Note: This is not a standard yes no field, we have used multiple choice for formatting reasons, so it's not true false, it is yes or no as the answer.
I figured the best way would be a mail script, but I'm getting an error in the notification advising that:
"Email script render error: email script [ variables_yes ] does not exist"
If someone knows how I can do this I'd really appreciate the help please.
The email script I'm trying is like this:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
if (current.variables.question1 == 'yes') {
template.print('*Are you going to attend?');
}
if (current.variables.question2 == 'yes') {
template.print('*Is the sky blue?');
}
if (current.variables.question3 == 'yes') {
template.print('*Do you like to swim?');
}
if (current.variables.question4 == 'yes') {
template.print('*Are you doing something on the weekend?');
}
})(current, template, email, email_action, event);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2024 06:29 PM
Hi @Bidduam
Can you share the screenshot of your notification body?
How are you testing the notifications?
The format looks alright.
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2024 09:09 PM
Worked it out.
Top left of the "What will it contain" tab, I changed the context type from HTML Only, to HTML and plain text.
Turns out if I'd done that at the start I wouldn't have had the issue!
Thank you for your help @Aman Kumar S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2024 07:07 PM
Hi @Bidduam
It could be possible that the email notification is inserting html <span> tags into your mail script calls. Please follow below steps and check if span tag is the culprit :
1. Go into the notification that is generating the error and click the < > button on the editor to open the source code editor.
2. Look for the tag with your mail script name like ${mail_script_name}. It likely has span tags in it so it looks like this: ${mail_script_name</span><span>}, which is causing the notification to be unable to find the mail script and run it.
3.Remove the span tags and retry.
Refer below posts for reference :
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2024 07:21 PM
HI @Bidduam ,
I trust you are doing great.
Please find the updated version of your script :
(function runMailScript(current, template, email, email_action, event) {
// Assuming 'variables' is a correctly set up variable set on the RITM form
// and each question is a variable within that set.
// It's also assumed that 'question1', 'question2', etc., are the internal names of the variables.
var questions = [
{variable: 'question1', text: 'Are you going to attend?'},
{variable: 'question2', text: 'Is the sky blue?'},
{variable: 'question3', text: 'Do you like to swim?'},
{variable: 'question4', text: 'Are you doing something on the weekend?'}
];
questions.forEach(function(question) {
var answer = current.variables[question.variable];
if (answer && answer.getDisplayValue() === 'yes') {
template.print('*' + question.text + '\n');
}
});
})(current, template, email, email_action, event);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2024 08:20 PM
Unfortunately this doesn't show anything - no error, but no values or text either