LogiUpSkill

Email Notification in Service-now

Email Notification :

Email notifications are a type of triggered email—email that’s sent in response to specific user action or an event.

Creating an email notification involves specifying when to send it, who receives it, what
it contains, and if it can be delivered in an email digest.

Types of Email Notifications:

  1. Outbound Email Notifications:
  • Sending mail to users from ServiceNow instance.
  • ServiceNow used SMTP to send the mail from the server.
  1. Inbound Email Notifications:
  • Receiving mails from user in ServiceNow instance
  • POP is used.

For email notifications, we have to set some settings.

Navigate to System Properties => Email Properties, the following list of properties will be displayed,

email notification in servicenow

In Outbound Email Configuration,

Select Email sending enabled and enter any random email address as shown in above snapshot.

In Inbound Email Configuration,

Select Email receiving enabled and at the bottom write the trusted domain from which ServiceNow should receive mails. If we enter star (*) then from all domains the email will be received.

Check “Automatically create users……..”  to create users automatically when any email is received from the user.

See below snapshot.

Outbound Notifications :

Create Outbound notifications for the incident table when the record is inserted..

Navigate to Configure => All => Notifications and click on New button as below,

The following form will be displayed. Enter condition in “When to send” section,

1.Send when : Record inserted or updated

Now select the user or group to whom the email to be sent as follows, User/Groups in field is form selected table. 

Configure the email as follows, 

Save the above form.

Now, Create a new record in incident table

Save the above record.

Since, short description contains “ashwini”, so as per the outbound notification we set, the email will be automatically sent to the mentioned user. The email engine process this mail.

  • First, this email will go in “Outbox” under System Mailboxes. In Outbox the mail is in Ready state. Email will be sent to the user, and it will be saved in Sent under System mailbox as follows

  • Since this email details are in Sent mailbox and its state is “Processed” that means the mail has been sent to the user which is mentioned as a recipient while creating Notification.
  • For recipient check notification as follows,

The mail will be like below,

To check the sender navigate to  Email Properties =>Email Accounts as follows,

If the user reply to this mail, it will be displayed in All=>Inbound =>Received

To check the received mails, navigate to System Mailboxes =>Inbound =>Received as below,

 

The email engine of ServiceNow will identify the “Reply” by the Ref no of the email which is send by the ServiceNow to the user as below,

2.Send when: user defined event is fired:

For that there should be a user defined event.

To create Event, navigate to Event Registry as follows,

(Fired by :to trigger this event we should write some code ,we can write it in business rule.write here the name of the business rule

Queue : whenever u r triggering any event it shd be the part of the system queue)

Click on Submit.

To trigger this event we need to write a script.(business rule or script include)

So create business rule to run after updating the incident record if short description contains “ashwini”

To trigger the event we have eventQueue().

  • Use the function eventQueue(“Your event name”,”the current object”, “parameter1”, “parameter2”)

Refer follow screenshots for business rule ,

Now change “Send when” option to “Event is fired” and keep all as it is in outbound notification as below,

Now update any incident and check the mail ,

 Now the mail should be sent to user as below,

To send the notification containing param values(passed in business rule while triggering the event) ,access param values in outbound notification as below,

Now again update any incident record and check the mail.

Mail Script :

  • Email scripts allow for business rule-like scripting within an outbound email message.
  • With mail scripts, you can dynamically change the email output of your system based on
    different criteria. Mail scripts allow you to perform simple tasks, such as displaying incident
    data, and complex ones, such as making advanced database queries.
  • You can add a ${mail_script:script_name}embedded script tag to the body of the email notification
    or template, replacing script name with the name of the script you created. This makes it easy
    to use the same scripts in multiple email notifications or templates.
  • Now to add email scripts in the body of our mail, first we will have to create
    mail scripts. To create a mail script open the Notification Email Script module and click on new.
  • We can write our code using template.print();

(Check below code in “message HTML” of Notification )

To see the code for mail script, navigate to System Notification => Notification Email Scripts

You will get the list of all mail scripts, search for the required one as below,

Now update incident record and check the mail,

Inbound Actions:

When the system receives the mail, it can be seen in inbox / received mail.

Inbound actions in ServiceNow are used to process incoming emails by creating or updating records within the platform. These actions are similar to business rules and use conditions and scripts to take action on a target table.

When an email is received, the system checks for a watermark that associates it with a task and other conditions. If the conditions are met, the system takes the inbound email action configured.

The system can take two types of actions: Record action, which sets a value for a field in the target table, and Email reply, which sends an email back to the source that triggered the action.

Navigate to System Policy => Inbound Actions and click on New button

The following form will be displayed.

Set the type as “New” and Action type is “Record Action”.

Available Types are:

  • New: An email that is not recognized as a reply or forward.
  • Reply: An email with a watermark, with an In-Reply-To email header, or whose subject line begins with a recognized reply prefix.
  • Forward: An email whose subject line begins with a recognized forward prefix, even if the email also contains a watermark or In-Reply-To header.

Set the condition as if Subject contains “ashwini” (if this condition met, inbound action will trigger)

Now set the Actions as below,

Now if any user sends an email whose subject contains “ashwini”, then as per the Inbound action condition, inbound action will trigger,

Check in Inbox,

After some time, it will go in Received mails,

Click on that record, Email details will be displayed as below,

You can see the value of Target, in the above screenshot Incident having Number INC0010227 is created,

Open that record.

As per the condition in Inbound Action, Sender of Email becomes Caller and Subject of email becomes short description.

You can preview this email by clicking on link under Related links at the bottom,

In Email log, you can see 2 incidents are created having number INC0010226 and INC0010227

To stop this, just check “Stop Processing” checkbox.

Now check the inbox/received mails again and check how many incidents are created for one mail.

Gmail:

Inbound: Inbox / Received

Click on this mail and check the Email Log, you will see only one incident has been created,

Scroll down, at the bottom check Email Log,

————————————— Overview ——————————————————-

Email Notification in Service-now

Leave a Reply

Your email address will not be published. Required fields are marked *