Mail notification to show variable values if equals yes

Bidduam
Tera Guru

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);

 

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hi @Bidduam 

Can you share the screenshot of your notification body?

How are you testing the notifications?

The format looks alright.

 

Best Regards
Aman Kumar

View solution in original post

13 REPLIES 13

Aman Kumar S
Kilo Patron

Hi @Bidduam 

Can you share the screenshot of your notification body?

How are you testing the notifications?

The format looks alright.

 

Best Regards
Aman Kumar

Bidduam
Tera Guru

I'm testing just by clicking on preview - works fine for all other parts and I've tried other known working mail scripts and they show fine, without any errors.

Bidduam_0-1707964663285.png

 

 

the name of the mail script is correct, right?

Can you check the source script of the email body by clicking on <> option in the toolbar and validate if everything looks alright there.

 

Best Regards
Aman Kumar

Yes it's named correctly - I copied and pasted it directly from the mail script title.

There is nothing in the html code that looks wrong:

<p style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">&nbsp;</p>
<ul style="margin-top: 0cm; margin-bottom: 0cm; list-style-position: inside;" type="disc">
<li style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">comply with the</li>
</ul>
<p>${mail_script:variables_yes}<br /><br /></p>
<p style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">&nbsp;</p>
<p style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">&nbsp;</p>
<ul style="margin-top: 0cm; margin-bottom: 0cm; list-style-position: inside;" type="disc">
<li style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">complete a &lsquo;new