- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2015 12:08 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2015 08:05 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2015 01:46 PM
Hi Harel,
Replace the statement 'current.setAbortAction(true);' with 'event.state="stop_processing";'
Or you can also rewrite the else if code like below,
else if (email.recipients.toString().indexOf('monitoring.network@MyCompany.com') > -1 && email.body.toString().indexOf("CLEARED:") == -1) {
createIncidentNetwork();
gs.log('HBS, createNetworkIncident');
}
Please try and let me know if any questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2015 06:30 AM
Hi Guhan,
Thanks for your answer!
Both options do not work. This is what I am using:
} else if (email.recipients.indexOf('monitoring.network@MyCompany.com') > -1) {
if(email.body_text.toString().indexOf("CLEARED: ") > -1) {
gs.log('HBS, Inbound action - not creating monitoring incident with the word create in it');
event.state="stop_processing";
}
createIncidentNetwork();
gs.log('HBS, createNetworkIncident');
}
What I am seeing in the log is both "HBS, createNetworkIncident" and also "HBS, Inbound action - not creating monitoring incident with the word create in it" so Incidents are still getting created. Seems that it is not stopping after processing...
Any more ideas?
Harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2015 06:41 AM
Harel,
Just try the below code in place of your else if
else if (email.recipients.toString().indexOf('monitoring.network@MyCompany.com') > -1 &&email.body.toString().indexOf("CLEARED:") == -1) { //create incident only if mail from monitoring and body doesn't contain word CLEARED
createIncidentNetwork();
gs.log('HBS, createNetworkIncident');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2015 08:15 AM
I'd also ensure that the body and the search phrase are both the same casing
email.body.toString().toLowerCase().indexOf('cleared: ')