Need to extract Incident Number or Change Number from inbound email action

Nasir1
Tera Expert

Hi,

Not so good with the scripting aspect and would appreciate if someone can help.

I have a requirement that needs to extract the Change or Incident number from email subject.

The email comes from same email address, but the subject line is different.

For example the Subject Line can be Unplanned Change : CHG123456789

Or Update: Unplanned Outage: INC123456789

How can we run the script that look at the subject and grabs the incident or change number?

 

Thanks in Advance

1 ACCEPTED SOLUTION

Hi,

add similar regex for CHG also

var subject = email.subject.toString();

var regex = new SNC.Regex('/CHG\\d{9}/im');

var match = regex.match(subject);

gs.info(match);

If my response helped please mark it correct and close the thread so that it benefits future readers.

regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

same thing for CHG

Your sample script will look like this when you use Inbound action

var subject = email.subject.toString();

var regex = new SNC.Regex('/INC\\d{9}/im');

var match = regex.match(subject);

gs.info(match);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader