- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 05:37 AM
Good Morning,
Can anyone help or point me to a tool OOTB that i can use to separate this subject line into multiple variables on a catalog item?
Subject Line = Termination for John Smith, 603677 (2025-01-10)
Trying to separate the name into one variable the number into another along with the date into a third. the body of the email is useless to use as everything is in the subject.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 06:10 AM
I'm guessing you are using an inbound action for this? You will have to script it. If it's always in this format, you can do something like this:
var subject = email.subject;
var arr = [];
subject = subject.substring(16); //Removes the "Termination for " beginning string
var commalocation = subject.indexOf(',');
var name = subject.substring(0, commalocation); //The name is the resulting string up to the comma
subject = subject.substring(commalocation + 1).trim();
arr = subject.split(' ');
var id = arr[0]; //The first part of the resulting string is the ID
var date = arr[1].substring(1, arr[1].length - 1); //The second part of the resulting string is the date in parentheses

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 06:10 AM
I'm guessing you are using an inbound action for this? You will have to script it. If it's always in this format, you can do something like this:
var subject = email.subject;
var arr = [];
subject = subject.substring(16); //Removes the "Termination for " beginning string
var commalocation = subject.indexOf(',');
var name = subject.substring(0, commalocation); //The name is the resulting string up to the comma
subject = subject.substring(commalocation + 1).trim();
arr = subject.split(' ');
var id = arr[0]; //The first part of the resulting string is the ID
var date = arr[1].substring(1, arr[1].length - 1); //The second part of the resulting string is the date in parentheses
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 06:14 AM
Does this work in the flow designer or do i have to use the inbound action area. it does always come in this format was trying to use flow but no luck.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 06:30 AM
You can probably still do it with Flow, but you would need to change it to use the Flow inputs rather than the email.subject line like in my script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 06:22 AM
you will have to perform string manipulation from that and extract values
Also if the pattern change in future then script needs to be updated as well
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader