Set Catalog Task due date based on a variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2010 05:16 PM
Hi,
Using my workflow to create a Catalog Task, I am trying to set its Due date based on a variable in my catalog item.
First, I couldn't find my variables in the Fields list in the tree. Specially when the option "duration field" is selectable, I thought I could just use this option to affect a "Date" variable from my request item to the due date of my TASK. Very confusing ...
I then used the "script" function to affect the value of my Date to the "answer" ... could make it work either. Some javascript function don't seem to work properly.
Here is the code:
var str = current.variables.PushDateTime;
var arrayDateTime = str.split(" ");
var date = arrayDateTime[0].split("-");
var time = arrayDateTime[1].split(":");
var dateTime = new Date(date[0], date[1], date[2], time[0], time[1], time[2]);
var result = dateTime.getTime() - new Date().getTime();
result = result.substr(0, result.length - 3);
answer = result;
I get the date value, create a Date object, get in seconds, then substract the date to the current date to obtain the number of seconds.
PushDateTime contains the value correctly. The split seems to fail ... I don't get anything out of it.
Maybe there is an easier solution ... I hope there is ...
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2010 05:37 PM
Assuming your variable is a date/time variable named 'PushDateTime', then you should be able to do this with a single line of script to set that variable value into the due_date field on your task.
You can use this in the 'Variables Catalog Task Advanced script' field on the workflow task activity.
task.due_date = current.variable_pool.PushDateTime;
Check this article out for more info on working with catalog variables in the variable pool.
http://wiki.service-now.com/index.php?title=Scriptable_Service_Catalog_Variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2010 05:44 PM
Thanks for the quick reply, I will give it a try.