Using an inbound email action script, how can I map values from the email to a field in servicenow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2016 02:38 PM
A user fills out a form and clicks submit via webpage.
An email is sent to our instance and creates an incident.
This is what a portion of that inbound email looks like:
First Name: John
Last Name: Smith
Employee Contractor Id: 8675309123
Email Address: john_smith@yahoo.com
I would like to take the email address provided in the body of the email and map it to the "caller_id" field in service now.
Currently I am using this script and it is not working:
if (email.body.Email_Address != undefined)
current.caller_id = email.body.Email_Address;
Please Help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2016 03:32 PM
Hi tmichals,
What was the script that worked for you?
I'm working on a similar requirement, the username is in the body of an email from an unknown mailbox and I need to take a string, extract the username and use it to assign the caller_id.
Be very grateful if you could share each step of your solution.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 07:32 AM
In order for the script to work, the user has to already be built in servicenow, the FROM email address has to be static, and every email must have the same general template. An example of the inbound email would be:
From: static@gmail.com <---- every email would have to be from this same address
First Name: John
Last Name: Smith
Username: jsmith123 <---- already a user on the sys_user table
In the inbound email action, use this script:
current.caller_id = email.body.username;
That script will look for the value after [Username:] in the email body, and map that value to the caller_id reference field.
Also, static@gmail.com would have to be built on the sys_user table with roles that allow it to write to the incident form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2016 07:15 AM
This is the script I ended up using:
if (email.body.email != undefined)
current.caller_id = email.body.email;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2016 04:45 PM
Caller_id is reference ..so it wont work.. I think you may have to parse email.body_text and extract the 'email Id' ( value ) and get it assigned to current.caller_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2016 05:56 PM
I would probably use a regex script to pull out the information after "Email Address:"
Ex.
var email = /\Email Address: (\S+@\S+);
if(email.body_html.search(email) >= 0)
{
//do something
}
thats the jists of it