- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2022 12:01 AM
We have a requirement of stop creating incident from certain only email from inbound email action. Please help to achieve this functionality. Actually we have one query added that if anyone sending mail to closed incident then it will create new incident but we can stop create it for one group only.
Thanks for your help.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2022 03:39 AM
Hi,
This can be done in two ways here:
1) Update your code as below:
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
// Implement email action here
if(email.from.indexOf('Your email ID to check')<-1){ // Replace your Email Address to exclue here
gs.include('validators');
if (current.getTableName() == "incident" && current.state != "7" && current.state != "8") {
var gr = current;
gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
gr.update();
} else if (current.getTableName() == "incident" && (email.recipients.toLowerCase().indexOf('test@mail.com') > -1) && (current.state == "7" || current.state == "8")) {
var gr1 = current;
var gr2 = new GlideRecord("incident");
gr2.initialize();
gr2.setValue("caller_id", gr1.getValue("caller_id"));
gr2.setValue("location", gr1.getValue("location"));
gr2.setValue("business_service", gr1.getValue("business_service"));
gr2.setValue("category", gr1.getValue("category"));
gr2.setValue("subcategory", gr1.getValue("subcategory"));
gr2.setValue("short_description", gr1.getValue("short_description"));
gr2.setValue("description", gr1.getValue("description"));
gr2.setValue("parent", gr1.getValue("sys_id"));
gr2.setValue("contact_type", "email");
gr2.work_notes = "This incident is created after email reply to closed incident number " + gr1.number + ":" + "\n\n" + current.work_notes.getJournalEntry(-1);
gr2.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
gr2.insert();
}
}
})(current, event, email, logger, classifier);
2) If this does not work, then Navigate to the module Email Filter as shown below:
a) Click on the module "Email Address Filters" as shown below:
b) Now click on New and define the Email Address and make sure to select Type as Deny as shown below:
https://docs.servicenow.com/bundle/sandiego-servicenow-platform/page/administer/notification/concept/c_EmailFilters.html
3rd Approach:
Create a system property where you store email addresses which you don't want to create an incident, then check that property from the condition on the inbound action.
Utilize this Property and check in condition of Inbound action like below:
if(gs.getProperty('Property Name').indexOf(email.from)<-1)
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2022 12:09 AM
Hi,
In your inbound you can try something as below
if(email.recipients.toLowerCase().indexOf('abc@gmail.com')>-1) //it checks for if the recipient contains email as abc@gmail.com
{// do not execute anyting
}
else
{//put what you want here
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2022 01:12 AM
Hi jaspal,
Thanks for your reply, I tried your code but still it is creating the new incident after sending a mail to closed ticket. Below is my code which i have tried, could you please help me on this.
gs.include('validators');
if (current.getTableName() == "incident" && current.state!="7" && current.state!="8") {
var gr = current;
gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
gr.update();
}
else if(current.getTableName() == "incident" && (email.recipients.toLowerCase().indexOf('test@mail.com')>-1) && (current.state=="7" || current.state=="8"))
{
var gr1 = current;
var gr2 = new GlideRecord("incident");
gr2.initialize();
gr2.setValue("caller_id", gr1.getValue("caller_id"));
gr2.setValue("location", gr1.getValue("location"));
gr2.setValue("business_service", gr1.getValue("business_service"));
gr2.setValue("category", gr1.getValue("category"));
gr2.setValue("subcategory", gr1.getValue("subcategory"));
gr2.setValue("short_description", gr1.getValue("short_description"));
gr2.setValue("description", gr1.getValue("description"));
gr2.setValue("parent", gr1.getValue("sys_id"));
gr2.setValue("contact_type","email");
gr2.work_notes = "This incident is created after email reply to closed incident number " + gr1.number +":" + "\n\n" + current.work_notes.getJournalEntry(-1);
gr2.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
gr2.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2022 01:31 AM
Replace
(email.recipients.toLowerCase().indexOf('test@mail.com')>-1)
with
!(email.recipients.toLowerCase().indexOf('test@mail.com')>-1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2022 04:25 AM
Hi Jaspal,
Still new incident is creating from this email id. Is there any way to restrict this.
Thank you!!
