How to italicize a called value in an email notification?

Shawn Horley
Kilo Guru

Greetings Folks

I have a notification script that advises our end-users when we receive their message. The notification pulls the subject line from the New Call Short description field. What I am looking for is how I would italicize the short description so as to make it more readable for our end users.

I know that <i> </I> is the element tag that I want to use, but I am not sure how to get that part into my script properly to achieve the output I want.

My script looks like this:

//Script for notification to caller that Email was received 
(function runMailScript(current, template, email, email_action, event) {
	template.print('<p><font size="5" color="#808080" face="Calibri"><strong>');
    template.print("Greetings " + current.caller.first_name +",");
    template.print('</strong></font></p>');
    template.print('<p><font size="3" color="#808080" face="Calibri"><strong>');
    template.print("Your message for IT Support: " + current.short_description + " has been received. We will respond to you as soon as possible.");
	template.print('</strong></font></p>');
})(current, template, email, email_action, event);

And I want to set the "current.short_description" in italics

Any suggestions?

Cheers

A.

1 ACCEPTED SOLUTION

Joel Millwood2
Kilo Guru

Hi Arthwys,

You can insert the tags directly into the print output:

template.print("Your message for IT Support: <i>" + current.short_description + "</i> has been received. We will respond to you as soon as possible.");

 

View solution in original post

8 REPLIES 8

Greetings Jibarican

I am not sure if I follow your meaning here.

We are creating our own email notifications as the oob ones do not fit our purpose.

Are you suggesting that there is a better way?

Cheers

A.

That part is fine. Create notifications to server your purpose.

However, the script for such notification is overhead, complicated and an array of don'ts in programming. It's more maintainable to change this

(function runMailScript(current, template, email, email_action, event) {
	template.print('<p><font size="5" color="#808080" face="Calibri"><strong>');
    template.print("Greetings " + current.caller.first_name +",");
    template.print('</strong></font></p>');
    template.print('<p><font size="3" color="#808080" face="Calibri"><strong>');
    template.print("Your message for IT Support: " + current.short_description + " has been received. We will respond to you as soon as possible.");
	template.print('</strong></font></p>');
})(current, template, email, email_action, event);

to sys_ui_message

<table>
    <tr>
        <td>
            Greetings ${current.caller.first_name}, <br />
            Your message for IT Support: ${current.short_description} has been received. We will respond to you as soon as posssible.
        </td>
    </tr>
</table>

 and call it like so from the email notification script

template.print(gs.getMessage('sys_ui_message_key_name'));

 anything else isn't required. Not even the IIFE. there is no need to trigger another JavaScript tick when it can be bypassed given the script isn't doing anything but printing plain text

And being an utter noob at Programming/Coding/Scripting I have to ask the question: IIFE?

I have no idea what IIFE is...

 

Thank you for your feedback Jibarican! it is important to me that I am building my environment in the best way possible! and I find guidance such as your to be invaluable!

 

Cheers

A.

An IIFE is an immediately invoked function expression. It means that upon JavaScriot seeing (function (){}, it executes it to run the code inside. This is ServiceNow's way to deal with JavaScript variable collisions. It is a redundant approach to make up for SNows lack of support for library Management. In your case, because the script is not doing anything but printing data, the IIFE is redundant. It's like pouring water into an already full glass.