set a timer in workflow based on a variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2013 10:04 AM
Is it possible to create a workflow timer based on a variable date?
The termination date is defined as a date type in the variable set. I would like to put a timer in the workflow to send a task to the HR dept 14 days before the termination date.
I don't know if I can create a timer in a workflow based on a variable.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2013 02:09 PM
I know you probably don't want to script but I did the work for you :). Just replace *insertName* with your variable name you should be good to go. I have also provided links on the wiki.
http://wiki.servicenow.com/index.php?title=GlideSystem_Date_and_Time_Functions#daysAgo.28int.29
http://wiki.servicenow.com/index.php?title=GlideSystem_Date_and_Time_Functions#dateDiff.28String.2C_String.2C_boolean.29
http://wiki.servicenow.com/index.php?title=GlideSystem_Date_and_Time_Functions#nowNoTZ.28.29
//Put catalog variable in easy to read variable. You will want to replace *insertName* with the variable name.
var dateTime = current.variables.*insertName*;
//Count back two weeks from date entered.
var twoWeekearly = dateTime.daysAgo(14);
//Find the difference between now and when HR should be notified in seconds.
var seconds = gs.dateDiff(gs.nowNoTZ(), twoWeekearly, 1);
//Return the answer to the timer activity to wait that many seconds.
answer = seconds;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2013 02:19 PM
If you want to script tgryziec's script will work. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2020 10:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2020 10:37 AM
Do you see Line No 4 Correct?
gs.noNoTZ()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2013 06:31 AM
Thank you both.
I tried the script but it did not work. The task was created immediately.
the variable containing the term date is called "end"
it is part of a variable set. would that change the script at all?
I included screenshots of the workflow and the timer.