Reprocess event through script

Abdul Azeem1
Tera Contributor

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

3 REPLIES 3

shloke04
Kilo Patron

Hi @Ajim Shekh 

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:

find_real_file.png

Right click on the highlighted Red portion and copy the query as shown below which you can use in the above script:

find_real_file.png

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

Thanks Shloke, for your quick response.

I'll try this on my PDI first if worked then I'll proceed accordingly.

Sure @Ajim Shekh . Let me know if you have a follow up query.

If your query is resolved, please mark my answer as correct and close this thread for others.

Regards,

Shloke