We’ve developed some resources to help you work effectively from home during COVID-19 Click here to learn more

Same day / Next day deadline

Hi,

 

In stead of creating a priority that creates a deadline within x hours, I would like to have a deadline that is calculated on the end of the day or eind of next day.

How can I approach this? Is it possible to overwrite the deadline calculated by the priority, based on my own calculation?

 

Thanx in advance!

Niels

RE: Same day / Next day deadline

Hi Niels,

I would create an event handler "Request changed priority" where you calculate the date and set a new deadline.

Something like this

Integer ticketId = getVariable("ticketId").toInteger();

Ticket t;
t.load(ticketId);

WeekSchedule ws;
ws.loadFromPriority(t.getValue("priority").toInteger());

DateTime dt;
Integer weekDay = dt.getWeekDay();

String timeStop;
if(weekDay == 0)
  timeStop = ws.getMonStop().toString();
else if(weekDay == 1)
  timeStop = ws.getTueStop().toString();
else if(weekDay == 2)
  timeStop = ws.getWedStop().toString();
else if(weekDay == 3)
  timeStop = ws.getThuStop().toString();
else if(weekDay == 4)
  timeStop = ws.getFriStop().toString();
else if(weekDay == 5)
  timeStop = ws.getSatStop().toString();
else if(weekDay == 6)
  timeStop = ws.getSunStop().toString();

t.setValue("deadline", dt.toString().before(" ") + " " + timestop);
t.save();

Of course, I'd test this code first, but atleast you'd be able to change the deadline to the end of the current day. You can also change the code a little to load the date of the current deadline, and just change the time till the end of office hours.

By: Simen Mostuen Iversen 6 Sep 2017