Reprocess event through script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 03:55 AM
Hello Experts,
I have a bunch of cases created but due to some business rule code[current.setWorkflow(false)] notifications are not triggered. So is there any way to re-trigger those notifications through script.
If anybody have any idea on it please let me know.
Appreciate your advice!!
Many thanks!!
Ajim
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 04:56 AM
Hi
There are couple of ways you can do it. You need to set the state of those sent emails back to "send-ready" again and automatically Servicenow job will processs it in next run which is of every 2 minutes(I remember).
So you can make use of below script which you can run in background to reprocess them:
// Set queryString with the query to perform -- USE CAREFULLY
queryString = "Add your query here"
var gr = new GlideRecord('sys_email');
gr.addEncodedQuery(queryString);
gr.query();
while (gr.next()) {
gr.type = "send-ready"; // this is the first update
gr.update();
gr.mailbox = "outbox"; // note this happen as a second update
gr.state = "ready";
gr.update();
}
You can get the query by navigating to the Email log table and then run the filter which you want as shown below:
Right click on the highlighted Red portion and copy the query as shown below which you can use in the above script:
Please refer the below article which explains in details on other approaches as well which you can follow:
https://community.servicenow.com/community?id=community_blog&sys_id=12dde6e9dbd0dbc01dcaf3231f9619d9
https://community.servicenow.com/community?id=community_question&sys_id=a1cee9d8db246b04a8562926ca96194b
Please be careful since you are dealing with emails so that no unnecessary email does not get trigger and create unwanted noise 🙂
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 05:28 AM
Thanks Shloke, for your quick response.
I'll try this on my PDI first if worked then I'll proceed accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 06:30 AM
Sure
If your query is resolved, please mark my answer as correct and close this thread for others.
Regards,
Shloke
Regards,
Shloke