Extract text from inbound email and post to description field on target record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 11:19 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 08:55 PM
Thank you. It's almost there. I am currently populating "Ticket" or "#11678150" instead of the entire string.
I have found it to be slightly easier because I can simply parse the subject of the inbound email instead of the entire body.
The of the email looks like this: Ticket#11678150 / Ocena / Ocena - Change CHG0015407 has been created - Status Update
Also, could it be possible to only add the Ticket#11678150 to the end of the short description without erasing what's previously there?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 09:12 PM
Hi there,
How is your short description generated now?
Maybe this gives some ideas:
current.setValue('short_description', current.short_description + ' your additional tekst' + string;
or
grIncident.setValue('short_description', 'your short description' + string1);
or is it about "Ticket#11678150 / Ocena / Ocena - Change CHG0015407 has been created - Status Update" and moving the Ticket part to the end?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 09:17 PM
The way that it is setup is that once a change request is initiated in SNOW, a notification is sent to the external system. Once the external system replies, the email is sent to the activity log.
So in addition to the short description of the ticket, we would like to have the ticket number from the external system placed there. The subject "Ticket#11678150 / Ocena / Ocena - Change CHG0015407 has been created - Status Update" is from the email from the external system.
So if I could parse it and get the Ticket#xxxxxxxx before the first forward slash(/), everything should be fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 09:19 PM
So far, this is what the code looks like now:
(function() {
var str = email.subject;
var ticket = str.substring(str.lastIndexOf("Ticket# "), str.lastIndexOf("#")).trim();
current.short_description = ticket;
current.update();
gs.log(ticket);
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 09:19 PM
So far, this is what the code looks like now:
(function() {
var str = email.subject;
var ticket = str.substring(str.lastIndexOf("Ticket# "), str.lastIndexOf("#")).trim();
current.short_description = ticket;
current.update();
gs.log(ticket);
})();