Delay task Creation

Brian Lancaster
Tera Sage

In the workflow is there a way to delay the second task from being created based on date picker variable?     Basically I have a request that has a start and end date.   The first task will be crated right away but the second task will be crated based on the end date put in by the user.

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Brian,



So it means that the first should be completed as per its end date..Right?


If so you can use the checkbox "wait for completion" on the task activity on the workflow.


No the first task is to give a user special access it will be close on the start date.   The second task needs to be created based on the end date and the user will loose the access they got on the first task.


Timer activity in the workflow -->Timer Based on : A date/time or duration field


Select field



Will this work ? Could not figure out if it can refer a variable of the catalog.Else if you can set your end date variable to a field on catalog item ,then this might work.


i I could not get the timer to pull from a variable so I wrote the following




//get server_decomEFFECTIVEdate variable  


var server_decomEFFECTIVEdate = new Packages.com.glide.glideobject.GlideDateTime();  


server_decomEFFECTIVEdate.setDisplayValue(current.variable_pool.server_decomEFFECTIVEdate.getDisplayValue());  


 


//convert to millisecond value and add specified time  


var server_decomEFFECTIVEdateValue = server_decomEFFECTIVEdate.getNumericValue()  


server_decomEFFECTIVEdateValue += (1000*60*60*24*10); //Add 10 days  


 


//write offset time to datetime variable  


var offsetDate = new Packages.com.glide.glideobject.GlideDateTime();  


offsetDate.setNumericValue(server_decomEFFECTIVEdateValue);  




//write comments to RITM  


current.comments = '"Additional task on hold until: ' + offsetDate.getDisplayValue();



//return difference from current time to offset time in secs  


answer = gs.dateDiff(gs.nowDateTime(),offsetDate.getDisplayValue(),true);