How to incident priority from inbound email

michaek123
Kilo Explorer

How do I set the priority in a new incident created from an inbound email?


I've tried adding the line:

Priority: 1

to the body of the email, expecting it to change the priority to "1 - Critical", but it just ignores it (always set to "5 - Planning").

I'm using an unmodified ServiceNow config instance.

Regards,

Michael

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

The inbound email is a script, so you w


ould need to something like:



current.priority = 1;


What do I put in the email message body to set the priority?



Inbound actions for Create Incident looks like below, so what is "email.body.priority"?



Michael






current.caller_id = gs.getUserID();


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


current.short_description = email.subject;




current.category = "request";


current.incident_state = 1;


current.notify = 2;


current.contact_type = "email";




if (email.body.assign != undefined)


    current.assigned_to = email.body.assign;




if (email.importance != undefined) {


    if (email.importance.toLowerCase() == "high")


          current.priority = 1;


}




if (email.body.priority != undefined)


    current.priority = email.body.priority;




current.insert();


Section 7 of the Inbound Email Actions wiki should give you the info you're looking for:


http://wiki.servicenow.com/?title=Inbound_Email_Actions#Setting_Field_Values_from_the_Email_Body



Basically you have a new line in your email body that contains "word:" the inbound email processor can pretend whatever follows is a variable.   You call that variable via current.body.word.



So in your case, that inbound email should look like this...



Sauce.png



... more or less. assuming the script looked for email.body.priority = high then current.priority = 1.


ServiceNow uses name:value pairs to set the values.



So if the inbound action has


current.priority = email.body.priority;



Your email into ServiceNow would have to have the following text at one point:


Priority:1



The first piece of code I gave you was to hardcode a priority of 1 in your inbound action. If you had already tried with name:value pairs and it didn't work it's possible there's a business rule or something overriding the value you set in the inbound action. For example, if impact and urgency are driving the priority you might have to set those from the inbound action.