- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 07:41 AM
I'm having some difficultly with what solution to use for following requirement:
User fills out catalog form and chooses a date. Another date is auto-populated with date 8 months in the future. Once submitted and tasks completed, there should be a timer or a wait activity (??) that will send an email 2 weeks before date is met (and again 1 week before date).
Not sure how to do this - I set a timer and added this code. But does it keep checking? :
var difSeconds = gs.dateDiff(gs.nowDateTime(), current.variables.return_date.getDisplayValue(), true);
gs.log('seconds: '+difSeconds);
if(difSeconds == 1209600){
answer = true;
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 09:42 AM
Hi
There was a similar question recently, which I answered in detail at the following URL:
This is using the Workflow and is quite simple to achieve. You can just give it a shot, instead of writing your Scheduler.
Let me know if that answers your question and mark my answer as correct and helpful.
Enjoy & BR
Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 08:27 AM
You can easily use flow designer to achieve this
but if you wish to use workflow then below should help
when the OOB answer variable becomes 0 it will proceed; till that time it will always calculate
please use this script in timer script to wait for 2 weeks
var gdt = new GlideDateTime(current.variables.return_date);
gdt.addDaysUTC(-14); // 14 days
answer = gs.dateDiff(new GlideDateTime(), gdt, true);
please use this script in timer script to wait for 1 week
var gdt = new GlideDateTime(current.variables.return_date);
gdt.addDaysUTC(-7); // 7 days
answer = gs.dateDiff(new GlideDateTime(), gdt, true);
Flow Designer:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 08:41 AM
Ankur - Thank you.
I think I may take a different approach to this. Instead of leaving a workflow open for minimum of 8 months, I may close the workflow, run a job and when dates meet criteria, send emails. Once date equals current date, generate a new workflow to complete work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 09:03 AM
Hi,
Just to inform the job will be running daily at particular time and checking for the required condition.
Another approach would be using BR, event and script action approach. The event will be scheduled and processed 2 weeks before the date.
Let me know if that answered your question.
If so, please mark response as correct & helpful
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 10:08 AM
Thank you for the suggestions ... definitely need to think about this. Thanks again