Update incident from email with no watermark AND 2 incident numbers in the subject line

Ricky S Larsson
Tera Guru

I'm trying to setup an inbound email action for an integration between the customer and their vendor that will update an existing incidents in the customer instance based on the INC number that is included in the email from the vendor. No watermark is included. I know there is a possibility to create an inbound action that doesn't require a watermark, just the ticker number.

Problem is, there is also another INC number (the vendor's INC) in the reply email from the vendor. The email subject line looks like this:

[Vendor's INC number] - New ticket from Customer [Customer INC number] has been assigned to Group

How would I setup an inbound action that could take the Customer INC number and match it to that incident and update it, and ignore the Vendor INC number?

Web Services / REST integration is out of the question at the moment as this vendor doesn't work with WS / REST

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hi Richard,

A quick fix would be to read the subject and then fetch the customer INC number.

To do that, you need to have 1 word at least constant (pre or post) of that customer INC number. Let say, Customer followed by XXXXXX would always be there. In that case, you can simply write below code which returns the customer INC number.

var subject = "XX3234241 - New ticket from Customer 787XX2342 has been assigned to Group";
var find_str = subject.indexOf("Customer");
if (find_str > -1) {
var customer_str = subject.substring(find_str,subject.length);
var customer_no=customer_str.split(" ");
gs.print("customer number is "+customer_no[1].trim().toString());
}

Mark the comment as a correct answer and also helpful once worked.

View solution in original post

10 REPLIES 10

It's supposed to be Reply but I have it as New for now because of testing, since I cannot create a Reply email inside the Dev environment (or at least I don't know how)

I checked the logs and found out that the following line:

var customerNo = array[1].trim().toString(); // Take index 1 which is the INC number, trim and display as string

gets index 1 which is from and not the INC number

so Ticket must be 0 and Company 2. So I will try to get index 3 instead

So if I changed the index from 1 to 3, AND changed 'Incident' to 'incident' then I managed to catch the INC number and now all the gs.logs went through as well. Which is nice 🙂

The weird thing though is that the inbound action doesn't update the incident according to the log (also it has no Target):

find_real_file.png

 

But the incident still manages to get comments. Are comments not part of updating an incident?

find_real_file.png

 

So it seems to be working but still not? I'm confused by the Email log...

Hi Richard,

The email log shows all the inbound actions that got run and their associated output. So check if your inbound action is executed or not. Also, if you got the comments, then it means the incident is updated. 

Let me know if you have any other question. Otherwise, kindly mark my comment as a correct answer.

Ashley25
Kilo Contributor

Richard,

I know this is an older case however I just thought I would throw a slightly simpler way of doing this that would also not require a static word to be present:

var incRegex = '/(?<=INC[0-9]{7} -.+)INC[0-9]{7}/'
var snRegex = new SNC.Regex(incRegex);
var matchedNumberIncident = snRegex.match(email.subject);
if (!JSUtil.nil(matchedNumberIncident)) {
//Do Thing using matchedNumberIncident as the customers INC
}

Link to the regex in action - https://regex101.com/r/eSNe3E/1

You could simplify this by dropping 'incRegex' and just using the string however for readability and future use I wouldn't advise this.

 

Ash