Extract text from inbound email and post to description field on target record

John Prahn
Kilo Contributor

Hi All, 

I have a requirement to extract data from an inbound email and post to the short description field on the target record. 

We have an integration setup using notifications and when the record is initiated on the other system, it will respond in email with that ticket number. 

I have attached a sample of the inbound email. I am looking to extract the line: Ticket #xxxxxxxx. 

 

Thanks in advance!

30 REPLIES 30

Hi John,

Did this solve your question? Or do we need to follow up on this?

Please mark this answer as correct if it solves your problem. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi John,

Did this solve your question? Or do we need to follow up on this?

Please mark this answer as correct if it solves your problem. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Try like this

Hi, Try this code and it shoudl work.

var ticket = email.subject;
ticket = subject.split("/");
gs.log(ticket[0]);
var sub = current.short_description;
current.short_description = sub + " - " + ticket;
current.update();

This is not going to work if there are multiple slashes as mentioned in one of the earlier posts.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

I thought what is needed is the string before the 1st slash and ignore all others.

So 

ticket = subject.split("/");

ticket[0] returns the string before the first slash.