
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2020 07:33 AM
Hi Everyone,
I have a requirement from client to send 3 days incremental reminder notifications when the record is unattended by the respective users. For accomplishing this I have written a schedule job but unsure How I can have a increment variable which gets factored when the schedule job runs and check if the record was unattended and sends notification on every 3 days, 6 days, 9 days so on until the record is actioned.
Below is the script that I have written to attain it - which is not complete. Any suggestion to meet the above requirement is highly appreciated.
(function(){
var startDate = '';
var incrementaldays = 3;
var counter = 1;
var nDate = '';
var gr = new GlideRecord('table_name');
gr.addQuery('workflow_state','3');
gr.query();
while(gr.next()){
startDate = new GlideDateTime(gr.start_state);
startDate.getDate();
nDate(startDate.addDaysUTC(incrementaldays));
}
if(nDate == new GlideDate()){
gs.eventQueue('3_incremental_sme',gr);
}
})();
(function(){
var startDate = '';
var incrementaldays = 3;
var counter = 1;
var nDate = '';
var gr = new GlideRecord('table_name');
gr.addQuery('workflow_state','6');
gr.query();
while(gr.next()){
startDate = new GlideDateTime(gr.start_state);
startDate.getDate();
nDate(startDate.addDaysUTC(incrementaldays));
}
if(nDate == new GlideDate()){
gs.eventQueue('3_incremental_tl',gr);
}
})();
Thank You for time and effort
Regards,
Imran
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2020 07:44 AM
Hi,
try something like this in your schedule job script
enhance it as per your need
var gr = new GlideRecord('table_name');
gr.addQuery('workflow_state','3');
gr.query();
while(gr.next()){
var termiDate = new GlideDateTime(gr.start_state);
var today = new GlideDateTime();
var dur = new GlideDuration();
dur = GlideDateTime.subtract(today, termiDate);
var dayCt = dur.getNumericValue();
dayCt = (dayCt / (60 * 60 * 24 * 1000));
dayCt = Math.round(dayCt);
gs.info(dayCt, 'dayCT');
if (dayCt == 3 || dayCt == 6 || dayCt == 9) {// if the difference between date is 3, 6 and 9.
if(dayCT == 3){
gs.eventQueue('event name 3 days', gr, );
}
if(dayCT == 6){
gs.eventQueue('event name 6 days', gr, );
}
if(dayCT == 9){
gs.eventQueue('event name 9 days', gr, );
}
}
}
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
‎10-30-2020 07:46 AM
Hi Imran,
you can also leverage the flow designer capability for this
Approval Reminder Notification for Change records using 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
‎10-30-2020 07:59 AM
Hi Imran,
Instead of using a Scheduled Script, the best way to achieve this is via a Workflow. Here is a sample workflow that you can think of.
- Create a workflow on sysapproval_approver and provide condition if you want to apply this reminder to on RITMs.
- The first activity is checking whether the State already reached to Approved/Rejected and if so end the process.
- If still open, then use the Timer. In the Timer, select Time based on "a Relative Duration". Here select 3 Business days as duration. Note: In case if you are not able to find this, create a custom one like this.
-
var days = 3;
if (calculator.isAfter(calculator.startDateTime, "10:00:00")) {
days++;
}calculator.calcRelativeDueDate(calculator.startDateTime, days, "16:00:00");
-
- After completing 3 days, again check whether the approval state goes to approved/rejected. If not, Create event and point to "3_incremental_tl"
You also have a sample Flow Designer Project for sending reminders. Click Here to download the Project and try on your own.
Thanks,
Narsing

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2020 08:09 AM
Instead of scheduled job, you should configure to send reminders for approvals like below workflow
this workflow uses a existing chase counter flag on approval table along with timer workflow activities.