Inbound Email Action Script ServiceNow | How to Create Inbound Email Action

In this article you will get the information related to inbound email action is ServiceNow along with this use case and its solution along with the script is mentioned below which will help you to implement inbound email action Script in ServiceNow instance. So lets begin

ServiceNow Inbound email actions is a configuration which tells that how and what your ServiceNow instance will respond, when it receives email from user. The responses are based on the content of the email received.

Inbound emails action use conditions and scripts to perform action on the targeted table.

What ServiceNow Inbound email action will check on the email received?

When email is received inbound action will check watermark, prefixes such as Fwd:, Re:, email body content such as From:, conditions texts etc. But if any of the email does not contain the watermark and required prefixes, then inbound action will create the incident from the message and if the email contains the watermark then it will treat it as reply and update the record accordingly.

Through inbound actions, ServiceNow instance can perform two things:

1. Record action : 

In record action new incident gets created or any existing record will get updated in service now instance

2. Email Reply: 

In email reply, ServiceNow instance reply an email to the sender after receiving an email from the sender and along with this if script is written for updating any of the record then, that record will also get updated.

How ServiceNow instance will come to know that email is new or forwarded email or sender has replied some thing back to ServiceNow instance?

When subject contains the prefix Fwd: and the email body contains the a string such as From: then ServiceNow instance will consider it as forwarded email.

When subject or email body contains the watermark  and in case if there is no watermark then Reply-To header should contains a recognized message ID of an email with a target record. Other then this if there is no watermark and email subject should contain a prefix RE: and a recognized  record numbers such as INCXXXX007, then ServiceNow instance consider it as replied email.

If there is no watermark, no prefix, nothing in the body text then, ServiceNow instance will treat it as new email and create the incident record for the same.

Use Case for practicing ServiceNow Inbound Email Action  is mentioned below:

User can reopen the resolved incident record by replying on the resolution email received by him. Along with this below information should also get reflected in Incident record.
Incident State turn to Reopen
Resolution Date should be filled.
Work notes should be updates such as: Incident Reopened By Username
Additional Comments will be updated

** Note: if your incident form state field does not contain reopen option then please do create it first and if your incident do not contain Reopened date field on the form then please do create. Both are displayed in below screenshot.

Incident Record


Below are the steps to implement this functionality ( Use Case):

1. Type inbound action in left filter navigator and click on inbound action module.
2. Click on New, Fill name, select target table as incident, select action type as Record action. check active checkbox
3. In when to run section, select type as Reply and give condition as "Body Text"  "contains" "not working"
4. In Actions section, give field actions as : State To Reopen
5. In Script Section paste the below script or you can modify the same as per your requirement.

var reopenUserName="";
var user=new GlideRecord('sys_user');
user.addQuery('email',email.from.toLowerCase());
user.query();
if(user.next())
{
reopenUserName=user.name;
}
current.work_notes = "Incident Reopened By " + reopenUserName;
current.u_reopened_date=gs.nowDateTime();
current.update();

We also given the demonstration of the same in our YouTube video. For video demonstration you can visit our YouTube channel "Basico ServiceNow Learning".

I hope above content helps you to implement or configure the inbound email action in ServiceNow and also have also given the idea related to ServiceNow inbound email action scripting. Please feel free to give you feedback in below comment box. Thankyou!!!

No comments:

Thankyou !!!!

Powered by Blogger.