Variables from Inbound Action

Andrii
Kilo Guru

Hi, I'm working on Inbound Action to populate specific fields on Incident record from inbound email.

Wiki here Inbound Email Actions - ServiceNow Wiki says that such pair Foo:bar from email may be accessed like this: email.body.foo

But does not matter how much I try - I can not get it's value - i always get "underfined"

Need help!

P.S. For now I use workaround - parsing email body with JavaScript String methods but a bit frustrated that can not use functionality that is written on Wiki.

1 ACCEPTED SOLUTION

Andrii
Kilo Guru

I found the answer !!!



Pairs like parameter:value only works when email has text format !!! Otherwise it is necessary to use Regex or parsing email body with JavaScript String methods.


View solution in original post

7 REPLIES 7

Mike Allen
Mega Sage

It is interesting.   When I use the inbound create incident, with the following amendments:



if (email.body.impact != undefined)


    current.impact = email.body.impact;


if (email.body.urgency != undefined)


    current.urgency = email.body.urgency;


if (email.body.assign != undefined)


    current.assigned_to = email.body.assign;



and send the following:


Capture.PNG


I get none of it working and the following comments in the incident:


Capture.PNG



When I sent the following:


Capture.PNG


with an extra line break between each variable, it worked fine:


Capture.PNG


I believe you and in my case:



Problem Id: PRB:39


State: New


Assignment Group: North America



it can not recognize any of these variables and returns undefined for:



email.body.problem_id


email.body.state


email.body.assignment_group



Is it written on Wiki that there should be additional line breaks?


And shat if I can not do additional line breaks due to a set of reasons?


For some of those fields that are reference fields, you may have to do http://wiki.servicenow.com/?title=GlideRecord#gsc.tab=0 lookups to set the field.



Also if you are running ServiceNow Fuji Patch 1, there are some bugs with Inbound actions.   However that was for event.state=stop processing.   I thought that match was still working



Here is some helpful information on inbound actions that may help.



OOB Inbound Action: Create Incident



This inbound email action is triggered when an email is sent to ServiceNow and the email is not a reply or forward.



This inbound email action can set the following fields on a new Incident:



assigned_to


priority



In addition to being able to explicitly set the values of the above fields within the email, the following is done automatically:



1. The Incident caller_id is set to the the user who replied to the email.


2. The email subject is set as the Incident short description.


3. The whole email is added to the Incident as a comment.


4. The Incident category is set to "request".


5. The Incident state is set to "1".


6. The Incident notify is set to "2".


7. The Incident contact type is set to "email".



Example email: This email will create a new Incident with the following:



1. The Incident caller is set to "Fred Luddy".


2. The Incident short description will be set to "Not able to connect to wireless network"


3. The whole email body is added to the Incident as a comment.


4. The Incident is assigned to "Bow Ruggeri" if the sender has the itil role.


5. The Incident category is set to "request".


6. The Incident state is set to "1".


7. The Incident notify is set to "2".


8. The Incident contact type is set to "email".


9. The Priority is set to "2" if the sender has the itil role.



-----




From: Fred Luddy <fred.luddy@example.com>


Subject: Not able to connect to wireless network


Date: June 11, 2013 1:44:55 PM PDT


To:               ServiceNow




The wireless network has been down for 30 minutes now.



assign: Bow Ruggeri




-----


Thank you, but this is not quite the answer to my question ...



I'm not yet working with reference fields- I can not get variables in the way Wiki says: variable:value



I had to use JavaScript to parse body_html instead.



But I hope that I'll find out why. However unsuccessfuly yet.