Inbound Action - Set Priority based on email created time

alhicks
Tera Guru

We have the below Inbound Action started and we'd like to base the Incident Priority on the time the email is received.     If, the email is received after normal business hours (after 5pm or weekends) then we want the priority to be a 1, instead of a priority 3.  

 

email.subject.toString().indexOf('Gentran Notification: Inbound Data Issue') ==0

 

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

current.short_description = email.subject;

current.description = email.body_text;

current.contact_type = 'email';

current.opened_by = 'AUTO OPEN';

current.caller_id = 'AUTO OPEN';

current.category = "Data Center/Infrastructure";

current.subcategory = "Facilities";

current.incident_state = 1;

current.priority = 3;

current.assignment_group.setDisplayValue('Command Ctr');

 

 

 

current.insert();

1 ACCEPTED SOLUTION

prdelong
Kilo Guru

I thought about this for a little while, but couldn't think of a relatively easy way to get the weekends and outside normal business hours. Using an assignment rule for the weekend is easy to set up without having to modify the inbound email action, and you can add/remove conditions as fit to better match the inbound emails.Screen Shot 2014-03-05 at 8.47.00 AM.png



As for the time of day, I wrote a rather inelegant, simple script to check the incoming time of the email. If you remove or comment out the "current.priority = 3;" line in the inbound action, you can stick this snippet before the "current.insert();" and that should take care of it.



// Grab the hour value from the gs.nowDateTime() function


// returns as a value 0-23




var time = gs.nowDateTime().split(" ")[1];


var hour = time.split(":");


var finalHour = parseInt(hour[0],10);




// Set the number equivalent to hours of normal business hours (8 = 8 AM, 17 = 5 PM)


// Make sure to manually check instance time


var a = 8;


var b = 17;



if ( (a > finalHour) || (finalHour > b)){




//Outside of business hours


current.priority = 1;


}




else{


current.priority =3;


// Inside normal business hours


}




View solution in original post

6 REPLIES 6

lawrence_eng
Administrator
Administrator

Hi,



For better visibility, I moved your question from the Community Updates & Feedback area to the Implement sub-community.



thanks,


Lawrence


--


Online Community Program Manager, ServiceNow


prdelong
Kilo Guru

I thought about this for a little while, but couldn't think of a relatively easy way to get the weekends and outside normal business hours. Using an assignment rule for the weekend is easy to set up without having to modify the inbound email action, and you can add/remove conditions as fit to better match the inbound emails.Screen Shot 2014-03-05 at 8.47.00 AM.png



As for the time of day, I wrote a rather inelegant, simple script to check the incoming time of the email. If you remove or comment out the "current.priority = 3;" line in the inbound action, you can stick this snippet before the "current.insert();" and that should take care of it.



// Grab the hour value from the gs.nowDateTime() function


// returns as a value 0-23




var time = gs.nowDateTime().split(" ")[1];


var hour = time.split(":");


var finalHour = parseInt(hour[0],10);




// Set the number equivalent to hours of normal business hours (8 = 8 AM, 17 = 5 PM)


// Make sure to manually check instance time


var a = 8;


var b = 17;



if ( (a > finalHour) || (finalHour > b)){




//Outside of business hours


current.priority = 1;


}




else{


current.priority =3;


// Inside normal business hours


}




Thank you so much, I'll give that a try.


just be aware that if you are basing your priority on Impact and Urgency (lookups) calculation, then you should set the urgency and impact in the inbound action, and let the Priority get calculated as normal. I wondered why mine wasn't working right 🙂