- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2019 11:58 PM
Hi All,
I am trying to design a solution where, the ticket is pending awaiting user response - if there no update from user within 24 hours, the email will be send and same on 48 and 72 hours.
if the user updates tickets, flow breaks and ticket status changes.
Considerations:
1.Ticket Status: Pending, awaiting User response.
2.Flow/rule executes: condition 1 is true and there is no update from user in ticket for 24, 48,73 hrs
3. Rule should: send email to user with defined template.
4.Tried to create scheduled job and event, notification - no luck with that.
I have tried to create a Scheduled job for this, but no luck.
Script:
var gr = new GlideRecord('incident');
gr.addEncodedQuery('active=true^state=3^sys_updated_onMORETHANsys_updated_on@day@after@1^sys_updated_by!=caller_id');
gr.query();
while (gr.next()) {
gs.eventQueue("chase.process", gr);
}
I have created event and notification for the same, but it is not working as expected.
Do we have any OOB solution for this or any advise on how can we achieve this?
Please advise..
Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- 13,631 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2019 02:55 AM
This sounds like a perfect use case for Flow tbh, not sure why you would use s scheduled job for this? Something like the below will send an email every 24 hours until the updated by is set to the caller. You'd need to refine it of course but it'll probably be more effective than a scheduled job and easier to configure and administer.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2019 12:07 AM
are you directly using the caller field on your notification ? if not then you have to pass it on your event param 1 parameter.
var gr = new GlideRecord('incident');
gr.addEncodedQuery('active=true^state=3^sys_updated_onMORETHANsys_updated_on@day@after@1^sys_updated_by!=caller_id');
gr.query();
while (gr.next()) {
gs.eventQueue("chase.process", gr, gr.caller_id,'');
}
Now, go to your notification and set the true on "Event parm 1 contains recipient" field.
once you will execute your scheduled job , check the event logs to confirm if you event has been executed or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2019 12:34 AM
Hello Ganesh,
1. Create 3 Events on incident table in event registry.
Event Names:
- incident.firstReminder
- incident.secondReminder
- incident.thirdReminder
2. Create after update Business rule with conditions STATE CHANGES to pending awaiting user response
Add below code:
(function executeRule(current, previous /*null when async*/) {
var gdt = new GlideDateTime();
gdt.addDaysLocalTime(1);
var firstReminder = gdt ;
gs.log("firstReminder: "+firstReminder);
gs.eventQueueScheduled ("incident.firstReminder" , current , gs.getUserID(), gs.getUserName(), firstReminder);
gdt.addDaysLocalTime(1);
var secondReminder = gdt ;
gs.log("secondReminder: "+secondReminder);
gs.eventQueueScheduled ("incident.secondReminder" , current , gs.getUserID(), gs.getUserName(), secondReminder);
gdt.addDaysLocalTime(1);
var thirdReminder = gdt ;
gs.log("thirdReminder: "+thirdReminder);
gs.eventQueueScheduled ("incident.thirdReminder" , current , gs.getUserName(), thirdReminder);
})(current, previous);
3. Create 3 Notifications for sending these three notifications with run condition is fired by event and STATE CHANGES to pending awaiting user response. Add your content whatever you want. Also you can add who will receive to send notifications to users.
You can see in Event Log when your notifications will trigger:
Please mark as Correct Answer and Helpful, if applicable.
Thank You!
Abhishek Gardade
Hexaware Technologies Inc.
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2019 02:34 AM
The issue is with your Query. You have updated by is not caller_id which is not a valid filter.
The FIlter should be something like below.
the above filter provides you the records that are not updated before 1 day. so as per your requirement you have to restrict it to between 24 to 72 hours
checking if the updated by is not caller should be done in while loop
script
while (gr.next()) {
if(gr.sys_updated_by != gr.caller_id.user_name)
gs.eventQueue("chase.process", gr);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2019 02:55 AM
This sounds like a perfect use case for Flow tbh, not sure why you would use s scheduled job for this? Something like the below will send an email every 24 hours until the updated by is set to the caller. You'd need to refine it of course but it'll probably be more effective than a scheduled job and easier to configure and administer.