Watermarks/ unable to create new incident as it's keep hitting existing ref number from email
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
So I have one business rule set up to different watermark:
(function executeRule(current, previous /*null when async*/ ) {
var bodyhastext = current.body;
bodyhastext = bodyhastext.replace(/Ref:MSG/g, '');
gs.info("watermark is "+bodyhastext);
//Suppose my watermark is of form : //Ref:MSG0042550 so it replaces it with empty
current.body = bodyhastext;
current.update();
//Ref:MSG0042550
})(current, previous);
Then got inbound action code to create new incident.
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
var lineOfText = email.subject.toString();
var incidentNumber = '';
var regex = /(INC\d+)/;
var match = lineOfText.match(regex);
// Check if the match array exists and has a captured group.
if (match && match.length > 0) {
incidentNumber = match[1];
gs.info("Found incident number: " + incidentNumber);
}
var gr = new GlideRecord("incident");
gr.addQuery("short_description", "CONTAINS", incidentNumber);
gr.query();
gs.info("COunt is: " + gr.getRowCount());
if (gr.next()) {
gs.info("line number 20");
var abc = new GlideSPScriptable().stripHTML(email.body_html);
gr.comments = abc;
gr.update();
}
else {
gs.info("line number 25");
var abc1 = new GlideSPScriptable().stripHTML(email.body_html);
current.caller_id = gs.getUserID();
current.description = abc1;
current.comments = abc1;
current.short_description = email.subject;
current.category = "inquiry";
current.incident_state = IncidentState.NEW;
current.notify = 2;
current.contact_type = "email";
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
if (email.importance != undefined) {
if (email.importance.toLowerCase() == "high") {
current.impact = 1;
current.urgency = 1;
}
}
current.update();
}
})(current, event, email, logger, classifier);
But it's still does not create me are new incident, it's just goes in to existing change task or existing request with watermarks, could someone share how to do it.
The main reason for this is, when we receive email from 3rd party ServiceNow to get automated incident created on our serviceNow. So when they send us an email we got existing watermarks on our serviceNow already.
0 REPLIES 0