set the priority of incidentsp as per the subject line in email (inbound email actions)

Gaddam Sai Srut
Tera Contributor

I had created incidents using inbound email actions but customer wants them to be created according to priority. for example if email subject line contains Non critical then the incident should be created with medium priority. if the email subject contains critical then the incident should get created with high priority. can i know how to achieve this. I tried using the below script in inbound email action but its not working. 

 

current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;
if(email.subject.indexOf("critical")>-1)
{
current.impact= "1";
current.urgency= "1";
current.priority= "1";
}
else if(email.subject.indexOf("Non critical")>-1)
{
current.impact= "2";
current.urgency= "2";
current.priority= "3";
}
current.incident_state = IncidentState.NEW;
current.category= "Scheduled Job Failure";
current.description= email.body_text;
current.insert(); 

2 ACCEPTED SOLUTIONS

BharathChintala
Mega Sage

@Gaddam Sai Srut 

var sub = email.subject;

current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = sub;


if(sub.indexOf("critical")>-1)
{
current.impact= "1";
current.urgency= "1";
current.priority= "1";
}
else if(sub.indexOf("Non critical")>-1)
{
current.impact= "2";
current.urgency= "2";
current.priority= "3";
}
current.incident_state = IncidentState.NEW;
current.category= "Scheduled Job Failure";
current.description= email.body_text;
current.insert(); 

 

 

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

View solution in original post

@Gaddam Sai Srut 

You can try like ask them to send critical or non critical in starting of subject

 

then in script

var sub = email.subject;

current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = sub;


if(sub.indexOf("Critical")==0)
{
current.impact= "1";
current.urgency= "1";
current.priority= "1";
}
else if(sub.indexOf("Non")==0)
{
current.impact= "2";
current.urgency= "2";
current.priority= "3";
}
current.incident_state = IncidentState.NEW;
current.category= "Scheduled Job Failure";
current.description= email.body_text;
current.insert(); 

 

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

View solution in original post

4 REPLIES 4

BharathChintala
Mega Sage

@Gaddam Sai Srut 

var sub = email.subject;

current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = sub;


if(sub.indexOf("critical")>-1)
{
current.impact= "1";
current.urgency= "1";
current.priority= "1";
}
else if(sub.indexOf("Non critical")>-1)
{
current.impact= "2";
current.urgency= "2";
current.priority= "3";
}
current.incident_state = IncidentState.NEW;
current.category= "Scheduled Job Failure";
current.description= email.body_text;
current.insert(); 

 

 

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

@BharathChintala 

 

The code is working fine but there is same keyword "Critical" in both the conditions so the incidents are getting with same priority. can you help me to generate them with different priorities with out changing the keyword. 

@Gaddam Sai Srut 

You can try like ask them to send critical or non critical in starting of subject

 

then in script

var sub = email.subject;

current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = sub;


if(sub.indexOf("Critical")==0)
{
current.impact= "1";
current.urgency= "1";
current.priority= "1";
}
else if(sub.indexOf("Non")==0)
{
current.impact= "2";
current.urgency= "2";
current.priority= "3";
}
current.incident_state = IncidentState.NEW;
current.category= "Scheduled Job Failure";
current.description= email.body_text;
current.insert(); 

 

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

Hi @BharathChintala,

 

This worked. Thankyou for the solution.