- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 11:36 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 07:40 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 11:41 PM
Hi,
you can use RegEx to get
Sample script like this
var str = 'Update: Unplanned Outage: INC123456789';
var regex = new SNC.Regex('/INC\\d{9}/im');
var match = regex.match(str);
gs.info(match);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 11:45 PM
Thanks How do I check the subject line in the same script if its change?
I am trying to avoid creating multiple inbound actions, since the email is coming from same email address only the subject line changes so I need a way to be able to extract either change or Incident number from subject
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 07:40 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2024 10:44 AM
Hi @Ankur Bawiskar
By using the above method, I could retrieve only one Incident number. Could you pls help here to retrieve more than one Incident from description field?