Reprocess email business rule script - assistance requested please

Robert T
Tera Contributor

Hello,

I've learned that ServiceNow is taking voicemails that get forwarded from our Microsoft system and sending them to the ServiceNow junk folder because they do not have an "@doman" component of the sending email.

Example of one of our ignored ones:

find_real_file.png

I've learned from a KB that the recommended workaround is to create a business rule that executes the "Reprocess Email" function, which will then cause emails of this type to run through our normal processes (which will create an incident with the VM as an attachment).  That KB is here: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0858378

The KB offers this script as a starting point for creating this:

(function executeRule(current, previous /*null when async*/) {
 var evt = new GlideRecord('sysevent');
 evt.initialize();
 var guest = new GlideRecord('sys_user');
 guest.addActiveQuery();
 guest.addQuery('user_name', 'guest');
 guest.query();

 if (guest.next()) {
  evt.user_id = guest.sys_id;
  evt.user_name = guest.user_name;
 }
 evt.process_on = gs.nowDateTime();
 evt.name = "email.read";
 evt.parm1 = current.sys_id;
 evt.insert();
 gs.addInfoMessage(gs.getMessage('Event created to reprocess email "{0}"',Packages.org.apache.commons.lang.StringEscapeUtils.escapeXml(current.subject)));

 if (current.type == 'received-ignored') {
  current.type = "received";
 }
})(current, previous);

 

The KB advises customizing the filter for the reprocess trigger, and at this point I am well out of my depth.

The goal is for any email where the sending user is "+" and then digits, with no @ sign, to be reprocessed as valid.  

If someone has the time to help advise this, start to finish, that would be brilliant and amazingly helpful.

Many thanks,

--Robert

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

Hi,

I've not tested this, but the following filter on your business rule should allow for the processing of the email:

find_real_file.png

View solution in original post

4 REPLIES 4

Kieran Anson
Kilo Patron

Hi,

I've not tested this, but the following filter on your business rule should allow for the processing of the email:

find_real_file.png

Thanks for sharing this.  I'm surprised it is not mentioned in the KB to just add a filter for when to run the script.  I'll give it a whirl.

I retract my statement.  It is working great, I just had to follow the KB determinant for the filter and use:

Type: received/ignored

Then you regex filter suggestion.

 

Thank you for the help! 

Cindy26
Tera Expert

I followed these instructions and created the business rule and it seemed to be working ok for the last 3 months. This week, it got stuck in a loop and we ended up with 13 million events in our event log, and inbound email has stopped processing. We are currently trying to resolve that mess. 

Would anyone be able to help with modifying this BR so that this does not occur?