- 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 09:47 PM
Hi,
should work fine
What's the issue faced?
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 09:57 PM
Last time when I did it via background script for testing purpose the and I got the tons of event getting triggered and all the events were in ready state and I had no option to process those events. I tried to kill the transactions but it creates the event in event table to kill it but due the already events are in ready state so I were not able to kill the transactions. I tried to delete those events via clean up policy OR background script but no luck.
So I am just afraid if I caught in same situation what can I do.
Please suggest.
Many thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2022 10:12 PM
always run such scripts in fix script so that you can cancel the execution
always test for limited records.
Please share your complete script and use setLimit(5) to check for 5 records and once it works fine then run the entire query
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:23 PM
If I run the background script to delete the record will it create any event in "sysevent" table ?
If yes then I guess I won't be able to delete those records.
Below is the background script which i tried
var gr = new GlideRecord("sysevent");
gr.addEncodedQuery("state=ready^table=sn_customerservice_case");
gr.setLimit(5);
gr.query();
gr.setWorkflow(false);
gr.deleteMultiple();