- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2018 04:57 PM
var sub = email.subject.toString();
var len1 = sub.indexOf("<");
var len2 = sub.indexOf(">");
var sdSub = sub.substring(len2); //Actual short description
var sdSev = sub.substring(0,2); // Severity
var sdCli = sub.substring(3, len1); //Core_Company
var sdBgr = sub.substring(len1, len2); //business group
len1 and len2 variables always returning null\no values which means value of sub and sdSub always same.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 01:34 PM
Thank you.
After a lot of trails i changed double quotes to single quote inside indexOf and it started working fine.
Somehow in my environemnt indexOf is not working when i use the double quotes. I was getting no value when i use the double quotes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 12:52 PM
What are you expecting out of len1 and len2. If you're checking to see whether the subject contains < or > you would need to add:
var len1 = sub.indexOf("<") > -1;
var len2 = sub.indexOf(">") > -1;
In that case you would get true/false values based on whether or not the subject contains < or>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 01:20 PM
My only guess would be to verify you are receiving what you think you are in the subject line. I just put exactly what you have in an inbound action in my PDI and it worked just fine. It sounds like what you want to do is parse out and break up information from the subject of an email. So in the inbound action I added this to print out each entity to the description field of an incident:
Then emailed in an incident and this is what was created:
So what you have seems to be working fine. Therefore I would check that your input (the subject) is what you expect, and work from there. Is there a possibility that the characters you are looking for (< and >) are not actually in the string?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 01:34 PM
Thank you.
After a lot of trails i changed double quotes to single quote inside indexOf and it started working fine.
Somehow in my environemnt indexOf is not working when i use the double quotes. I was getting no value when i use the double quotes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 01:58 PM
After rereading I realize my initial answer was off since you're looking for the position in the string. That being said, in javascript single and double quotes are interchangeable, so it's possible the email you tested with after changing the quotes was different. I would retest and make sure that it's working.