reminder notification flow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 07:33 AM
Hi,
I am having a requirement related to reminder notification...
once a ticket is in awaiting info state for 3 days, i have to send a reminder notification to user,
and after a 6 days also if the ticket is in awaiting info state.. i have to send a same reminder notification to the user.
and after 6th day i.e. on 7 th day i have to cancel that ticket.
i have created a scheduled job for that.. but some time it is not working
var grCase = new GlideRecord(' scoped custom table');
grCase.addEncodedQuery('active=true^state=18');
grCase.query();
while (grCase.next()) {
var ticket_updated_time = new GlideDateTime(grCase.sys_updated_on);
var today = new GlideDateTime();
var duration_seconds = gs.dateDiff(ticket_updated_time, today, true);
var duration_days = Math.round(duration_seconds / 60);
gs.log('scoped job' + duration_days + 'case : '+grCase.number);
if (duration_days == 5) {
gs.eventQueue('gbs.case.awaiting.info.notification', grCase);
gs.log('Reminder : 1 - reminder notification sent for this case using scheduled jobs : ' + grCase.number);
}else if (duration_days == 10) {
gs.eventQueue('gbs.case.awaiting.info.notification', grCase);
gs.log('Reminder : 2 - reminder notification sent for this case using scheduled jobs : ' + grCase.number);
}else if (duration_days > 10) {
grCase.auto_close = true;
gr.comments = 'test auto closure';
grCase.state = 7;
grCase.update();
gs.eventQueue('gbs.case.cancelled', grCase);
gs.log('case number : ' + grCase.number + ' cancelled by a scheduled script execution.');
}
}
for testing i am executing it on 5 and 10 minutes.
but this is not working. can anyone help me with that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 08:01 AM
Hi Priyansh_98,
One thing to consider is that because you are doing things in minutes, it is quite easy for objects to be at six or eleven minutes before you can run the job. I would suggest changing the timing to hours (just change your divisor to 360) and manually/programatically set your dates for testing.
What I have done to address the requirement that you describe is to create a workflow that gets activated when your condition (waiting for info) and then handles things automatically.
:{)
Helpful and Correct tags are appreciated and help others to find information faster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 12:43 AM
Hi @johnfeist & @Amitoj Wadhera ,
Thanks for your inputs..!!
I have tried workflow for this requirement and it worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 09:59 AM
Hi @Priyansh_98 ,
If you find my response helpful, please consider marking it as the 'Accepted Solution' and giving it a 'Helpful' rating. Your feedback not only supports the community but also encourages me to continue providing valuable assistance.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 08:12 AM
Hi @Priyansh_98 ,
Updated Script:
var grCase = new GlideRecord('scoped custom table'); grCase.addEncodedQuery('active=true^state=18'); grCase.query(); while (grCase.next()) { var ticket_updated_time = new GlideDateTime(grCase.sys_updated_on); var today = new GlideDateTime(); var duration_seconds = gs.dateDiff(ticket_updated_time, today, true); var duration_days = duration_seconds / 86400; gs.log('scoped job ' + duration_days + ' case: ' + grCase.number); if (duration_days >= 3 && duration_days < 6) { gs.eventQueue('gbs.case.awaiting.info.notification', grCase); gs.log('Reminder: 3rd day reminder notification sent for this case: ' + grCase.number); } else if (duration_days >= 6 && duration_days < 7) { gs.eventQueue('gbs.case.awaiting.info.notification', grCase); gs.log('Reminder: 6th day reminder notification sent for this case: ' + grCase.number); } else if (duration_days >= 7) { grCase.state = 7; grCase.auto_close = true; grCase.comments = 'Auto-closed due to inactivity'; grCase.update(); gs.eventQueue('gbs.case.cancelled', grCase); gs.log('Case number: ' + grCase.number + ' auto-closed by a scheduled script execution.'); } }
If you find my response helpful, please consider marking it as the 'Accepted Solution' and giving it a 'Helpful' rating. Your feedback not only supports the community but also encourages me to continue providing valuable assistance.
Regards,
Amitoj