When to run Inbound email action - exact email address

Bogdan18
Tera Guru

Hi guys,

 

In the Inbound email action in the When to Run conditions I have a few conditions so that the inbound rule will trigger only if the Recipients, To and Copied matches a pattern which is an email address.

So if the one sending the email is also putting that specific email address in To or CC we would like the inbound action to trigger.

The conditions work great but if that specific email address is followed by another email address then the conditions fail. 

1. If I put the instance email in the To field and in the CC field that specific email then the inbound gets triggered

2. If I put the instance email in the To field and then I also put the specific email in the To field then the Inbound does not get triggered

Any idea why this is failing like this?

 

Also the name of that specific email address is something general so we must make sure that if the name appears in other email addresses as part of those email addresses names the inbound action doesn't get triggered. That is why I used the match pattern conditions because it seems to do the work.

So lets' say the specific email address I mention above is "bo@servicenow.com" and I would like to trigger the inbound action only if the "bo@servicenow.com" appears anywhere in TO or CC. If someone with "bogdan@servicenow.com" sends an email to the instance the inbound should not trigger. Looks like if you use the Match pattern in condition this will be accounted for but then i get the problem in the beginning of this post.

Any help will be greatly appreciated.find_real_file.png

1 ACCEPTED SOLUTION

palmen
Tera Guru

You could script this if you want. Set condition to the following 

new yourScriptInclude().yourFunction(email.to)

In the script include you can then use email.to to look for if the desired email adress was in the to or cc field.

https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/administer/notification/referen...

View solution in original post

7 REPLIES 7

palmen
Tera Guru

You could script this if you want. Set condition to the following 

new yourScriptInclude().yourFunction(email.to)

In the script include you can then use email.to to look for if the desired email adress was in the to or cc field.

https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/administer/notification/referen...

Hi Palmen,

 

Thanks for point me in the right direction. I don't know what I would do without you awesome people.

 

So, for anyone out there this is the entire process explained:

1. I created a Script include. Don't forget to check the Client callable option.

var <<name of your script include>>= Class.create();
<<name of your script include>>.prototype = Object.extendsObject(AbstractAjaxProcessor, {

checkEmail: function(){
var str = <<name of your  email address or keyword you want to look for>>';
var gr = new GlideRecord("sys_email");
gr.query();
while (gr.next()) {
if(email.to.includes(str)){
return true;
}
else{
return false;
}
}
},

type: '<<name of your script include>>'
});

2. Went to the inbound action email and got rid of all the Conditions I had in the past and instead listed the script include in the Condition field like this: new <<name of your script include>>().checkEmail()

 

Thanks again Palmen,

Bogdan

 

Great that you found a solution, could you please mark an answer as correct so this thread doesn't show up as unsolved anymore, it will help others to find solutions as well.

Already did 🙂