Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Inbound action condition to skip creating incident

oharel
Kilo Sage

Hi all,

This might be a bit basic, but I can't get it to work:

I am trying to tell the inbound action to skip creating an incident if the body of the email contains the word "CLEARED: ".

I am trying something like this:

...

} else if (email.recipients.indexOf('monitoring.network@MyCompany.com') > -1) {

  if(email.body.indexOf("CLEARED: ") > -1) {

  current.setAbortAction(true);

  }

  createIncidentNetwork();

  gs.log('HBS, createNetworkIncident');

}

Using if(!email.body.indexOf("CLEARED: ") > -1) yields: confusing use of !

How do I tell the script to stop running?

How do I fix this if condition?

Thanks,

Harel

1 ACCEPTED SOLUTION

dwolf
Giga Expert

Hi,



I would try adding an email filter instead of using the inbound action.



The Email Filter plugin must be activated to work.


Create a new Filter and add the condition "Body contains cleared: "


Under filter actions you can mark is as ignored or junk (for testing I use junk)



Hope this helped.


Darla


View solution in original post

10 REPLIES 10

Hi Julian,



Thanks; it is definitely CLEARED with upper case, though.



Harel


dwolf
Giga Expert

Hi,



I would try adding an email filter instead of using the inbound action.



The Email Filter plugin must be activated to work.


Create a new Filter and add the condition "Body contains cleared: "


Under filter actions you can mark is as ignored or junk (for testing I use junk)



Hope this helped.


Darla


Like the idea, but not sure if that would work as the original message is also checking against a specific email address before it checks for the wording.


The filter can add multiple conditions like:


Recipient is monitoring.network@mycompany.com and other conditions.



This is what I have done to minimize our spam tickets:



Hi Darlene,



This is working, thanks.


I added a filter, as you suggested, to ignore email messages which contain the word CLEARED in the body of the mail.



Harel