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

Hi @Bidduam 

Yeah this looks alright, can you try to delete the mail script and try recreating it and validate.

 

Best Regards
Aman Kumar

@Aman Kumar S 

So apparently you and I were both right and my mail script works perfectly the way it was/is.

 

I created a new notification with nothing in the body of the email at all other than the mail script and it works perfectly.

 

So the issue appears to be the way it is being handled by the HTML around it.

Hi @Bidduam 

Glad it worked out for you.

Feel free to mark the response as correct so it ends up in solved queue, and help others looking for same.

Cheers!

Best Regards
Aman Kumar

Well it's sort of worked for me, the issue I have now is, how do I get it to work when it is placed inside the body of the email - as in not all by itself in the notification?

With the new notification, try to type in the details that you have instead of copying from the old one.

HTML formatting might be hampering your notification.

Give it a go, it should work

Best Regards
Aman Kumar