Using Workflow to set Due Date on Request Item from variable

User173809
Tera Contributor

We have a requirement to set the due date for certain items requested in our service catalog based on a user input field or 5 days from the opened date, whichever is greater.

For this, I am trying to set the due date using a Relative Duration script in the Schedule tab of the workflow. The problem is that this script always sets the due date to +5 days and doesn't seem to have access to the variables in the requested item. Any ideas on how to pull the variables into the Relative Duration script so that I can set the due date?

Relative Duration script:

// 5 business days by default
var days = 5;
// Set EndDate to 5 days out at 5pm
calculator.calcRelativeDueDate(calculator.startDateTime, days, "17:00:00");

// Get Start Date from RITM
var start = new GlideDateTime(current.variables.start_date);

//If Start Date is past current EndDate, extend EndDate
if (start > calculator.getEndDateTime()) {
	start.addDays(-2); //Adjustment to set EndDate to prior day's COB
	calculator.calcRelativeDueDate(start, 1, "17:00:00");
}
3 REPLIES 3

SanjivMeher
Kilo Patron
Kilo Patron

I think you can just use a run script and set teh due date

 

current.due_date = current.variables.start_date;


Please mark this response as correct or helpful if it assisted you with your question.

Sanjiv,

Setting the due date in this method does not take the end users time zone into account nor the schedule for business hours. While this isn't a huge showstopper because it can still be scripted, it takes this solution from one line of code to several lines of code that would need to be applied to each workflow. With the schedule tab in the workflow, all this can be set via some select boxes instead of dealing with selecting schedule sys_ids and getting user timezone settings via script.

Ultimately, our goal is to set an SLA for requests to use "Breach on Due Date" and set the due date via the workflows instead of making a separate SLA for each request.

If setting up request/ritm/sc_task SLAs is something you have had configured, what has worked best for you and what would you do differently if setting it up again? My goal is to have a configuration that is tied to each item so that it is easy to lookup and configure. 

If you want to set it globally, you should write a business rule. 

And add this current.due_date = current.variables.start_date;

 

You shouldn't take users timezone. It will automatically convert your date based on users timezone


Please mark this response as correct or helpful if it assisted you with your question.