- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2022 09:46 PM
Hey Team,
Good day!!
I am planning to fire the event via fix script to trigger the notification for cases opened. So I just wanted to know will there be any issues with this approach.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 05:09 AM
As I mentioned always run the script for few records to test it
try this
var grCase = new GlideRecord("sn_customerservice_case");
grCase.addEncodedQuery("sys_created_on>=javascript:gs.dateGenerate('2022-02-02','16:36:51')^sys_created_on<=javascript:gs.dateGenerate('2022-02-08','01:32:11')");
grCase.setLimit(5);
grCase.query();
while(grCase.next()){
var grEmail = new GlideRecord("sys_email");
grEmail.addQuery("subject","LIKE",grCase.number);
grEmail.addQuery("recipients","!=", grCase.contact.email);
grEmail.addQuery("recipients","!=", grCase.assigned_to.email);
grCase.query();
// use valid if condition
if(grEmail.getRowCount() == 0){
gs.eventQueue('event_for_email_reprocess', grCase, "","");
}
}
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
‎02-22-2022 10:27 PM
Hi,
the above code is just deleting the events and should be fine
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
‎02-23-2022 04:47 AM
var grCase = new GlideRecord("sn_customerservice_case");
grCase.addEncodedQuery("sys_created_on>=javascript:gs.dateGenerate('2022-02-02','16:36:51')^sys_created_on<=javascript:gs.dateGenerate('2022-02-08','01:32:11')");
grCase.query();
while(grCase.next()){
var grEmail = new GlideRecord("sys_email");
grEmail.addQuery("subject","LIKE",grCase.number);
grEmail.addQuery("recipients","!=", grCase.contact.email);
grEmail.addQuery("recipients","!=", grCase.assigned_to.email);
if(grEmail.next()==0){
gs.eventQueue('event_for_email_reprocess', grCase, "","");
}
}
The above script i ran in fixed script but tons of events got generated and still the events are generating. I deleted the event and disabled the notification but still the events are generating. I also tried by killing the All active transaction but no luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 05:09 AM
As I mentioned always run the script for few records to test it
try this
var grCase = new GlideRecord("sn_customerservice_case");
grCase.addEncodedQuery("sys_created_on>=javascript:gs.dateGenerate('2022-02-02','16:36:51')^sys_created_on<=javascript:gs.dateGenerate('2022-02-08','01:32:11')");
grCase.setLimit(5);
grCase.query();
while(grCase.next()){
var grEmail = new GlideRecord("sys_email");
grEmail.addQuery("subject","LIKE",grCase.number);
grEmail.addQuery("recipients","!=", grCase.contact.email);
grEmail.addQuery("recipients","!=", grCase.assigned_to.email);
grCase.query();
// use valid if condition
if(grEmail.getRowCount() == 0){
gs.eventQueue('event_for_email_reprocess', grCase, "","");
}
}
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
‎02-23-2022 09:30 PM
Perfect It works. Thank you Ankur:)
One query will be there any issue if I used getRowCount in production?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 09:36 PM
you should always test fix script in lower instances first and then run the actual one in production
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader