
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2018 05:23 AM
I want to know if it is possible to generate a task based on the date of a variable. If this is not feasible or there are many risks, could someone offer a solution based on this need.
So I have a catalog item that has a variable that is a date field. The way that I want this workflow to work is:
a. Customer submits the form,
b. All approvals go through,
c. An email goes to the customer letting them know that the access has been granted.
d. Once all tasks have been completed, I want the workflow to stop & wait but not close the RITM because the variable that is a date field I want a task to generate when that date has been reached.
Any assistance would be much appreciated.
Thank you,
Karen
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2018 06:38 AM
You can do something like below. add timer after wait for task timer
Timer
Name: Wait for End date
Time based on: Script
Script:
var endDate = current.variables.end.getDisplayValue();
answer = gs.dateDiff(gs.nowDateTime(), endDate, true);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2018 07:42 AM
You are welcome Karen.
I applaud your approach of leveraging the community and doing your research to find out *IF* it can be done and *WHAT* it will take to do it before saying "Sure!" and getting stuck with "Now, how do I do this?" only to find out it's a deep customization that will haunt someone for the rest of their ServiceNow life. 🙂
Good job!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 05:44 AM
Great thanks for your response,
I have also same kind of requirement but the timer should exclude 'weekdays and holidays'. Can you please help me following requirement.
Requirement 1 : We have a variable called 'Expiration Date'. If expiration date is -7 days send a email notification to requested for.
Script in Timer activity :
Requirement 2: If 'expiration date' is today, create a catalog task by tomorrow morning at 6 AM.
Script in Timer activity :
Thanks
Mani Polisetty

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2018 12:05 PM
I had to do the following to make the timer work for me, using date/time from a variable:
// Set 'answer' to the number of seconds this timer should wait
var powerDownDateTime = current.variables.srvr_req_decom_power_down;
var diffSeconds = gs.dateDiff(gs.nowDateTime(), powerDownDateTime, true);
answer = (diffSeconds - 18000);
I do not know why I had to subtract the 5 hours to make this work. Is the timezone wrong on my instance?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2018 12:13 PM
Yes, By default all date/time are stored in UTC.
https://docs.servicenow.com/bundle/jakarta-platform-administration/page/administer/time/reference/r_TimeZones.html

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2018 12:16 PM
add something like .getLocalTime() to get localtime