inbound email actions. Email address need to redirect to servicenow

sonita
Giga Guru

We received a request to create 2 new email address:  These email addresses will need to redirect to Service Now and then to the perspective assignment groups.

Any help please how o achieve this?

Anything sent to the email addresses will need to be assigned to prospective assignment groups

 

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

It's pretty easy to do.

1 - Setup forward rule on new email to forward all emails to SN.

2 - in your inbound action do something like below

if(email.to.toLowerCase().indexOf('email1@gmail.com') != -1){ //sysid of group that this email address belongs to
	current.assignment_group = 'sysid of group for that email';
}else if (email.to.toLowerCase().indexOf('email2@gmail.com') != -1){ //other group sysid
	current.assignment_group = 'sysid of group for that email';
}

View solution in original post

15 REPLIES 15

Cheyenne1
Kilo Guru

You will need to forward the email into your instance ServiceNow email address and then configure an inbound action. I can help you with the script, Do you want to create a service request or incident / other table ticket?

Thanks for your help ; I need to create incident tickets.

Ok sounds good. 

 

This should help you get started:

Navigate to System Policy -> Inbound actions

Create New

Target Table = Incident

Action Type: Record Action

Type: New

 

Your action script will look something like this:

current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;

var sid = '';
if (email.body.username != undefined){
var un = email.body.username;
var user = new GlideRecord('sys_user');
if(user.get('user_name', un)){
sid = user.sys_id;
}
else {
sid = 'entersysidoftheuserrecordhere'; // sys ID of the user record you want to set as the caller
}
}

current.caller_id = sid;
current.opened_by = 'entersysidoftheuserrecordhere';// sys ID of the user record you want to set as opened by
current.cmdb_ci.setDisplayValue('yourCIname'); //enter CI name if you'd like to set one
current.state = 1; // the state value on creation
current.contact_type = "email";
current.assignment_group.setDisplayValue('Assignmentgroupname'); //assignment group name

//You can also add this to set priority vs. what i have above 

//if (email.body.assign != undefined)
// current.assigned_to = email.body.assign;

//if(email.importance != undefined)
// if(email.importance == "High")
// current.priority = 1;
//
//if (email.body.priority != undefined)
// current.priority = email.body.priority;

//if (email.body.u_category != undefined)
// current.category = email.body.category;

current.insert();
event.state="stop_processing";

 

Let me know how it goes!

Sorry forgot to add: when to run tab

 

If you want to specify a specific user that will trigger the alert, add the user to the 'from' reference field

(you'll just have to create a local user account with that specific email address on the sys_user record)

If you want to specify a specific condition like: Subject contains something you'll want to add something like this: 
(email.subject.toString().toLowerCase().indexOf(' enter subject line here or specific word ') >=0 

Or if you want to specify more than one email address or the end of an email address:
email.from.toString().toLowerCase().indexOf('@something.com') >=0