Inbound Email - Getting original email address
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2012 10:41 AM
I am in the process of writing a script for an Inbound Email Action, but I am having an issue.
The script is meant to assign incidents to specific groups based on the from address on the inbound email. I'm running into trouble because the email.fromand email.origemail variables are both returning a name as opposed to an email address for some of the email addresses. There are some scripts in the instance that are using gs.CreateUser() and making users from inbound emails, which I think is part of what's causing ServiceNow to return a name as opposed to an email address.
I assume they're supposed to work this way for some reason, but is there any way to just read the actual email address (user@domain.com) as opposed to a name (User Name) in all cases? It stands to reason that it has to be accessible (since gs.createuser makes a user using the email address from inbound emails) but I can't find anything in the wiki that gives me any sort of clue how to do it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2012 04:48 AM
What do you mean by "insert into a field"?
In any case, what you can do to test is very simple. Write gs.log("email.from = " + email.from) and gs.log("email.origemail = " + email.origemail) at the beginning of your inbound action and then check the logs...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2012 07:12 AM
Ah, you've allowed me to solve it. Thanks.
I'm sort of learning as I go with ServiceNow, so if it's not explicitly in the wiki where I'm reading I tend to not know about things. I didn't even know the log existed, so I hadn't tried writing anything to it to check. Instead I was putting the contents of the variable in a comments field, assuming what was displayed there would be exactly what the script was seeing. Apparently that wasn't the case, hence my thinking it was replacing the email address with a name.
My if...else wasn't working because of a syntax error that was slipping through the cracks in the validator. Fixed that and all is well.
Thanks again.