Using Workflow to set Due Date on Request Item from variable

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2018 12:27 PM
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");
}
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2018 01:00 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2018 08:53 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2018 10:01 AM
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.