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

Thank you for the reply Mark.   After all this, the one that requested it to be setup based on time, ended up changing their mind.   )


How to determine if the time is in EST? ie. received after 5pm est and before 8am EST