Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Setting short description from email body and email subject

nrd5830
Mega Guru

In my inbound email action, I am trying to populate the short description of the incident with email subject and a line from the email body. 

Say the email body contains the line "Test:123" and the email subject is "Email Subject". I would like to append both "Test:" value and entire email subject both separated by a comma. How do I achieve this in an inbound email script?

Finally, a short description should look like

123, Email Subject

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi Nitish,

 

You can try using below lines

 

var bodytxt=email.body.test; //stores value 123 from the mail body

current.short_description=bodytxt+' ,'+email.subject;

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

View solution in original post

6 REPLIES 6

johnfeist
Mega Sage

Hi nitesh,

In your inbound action, you reference the various parts of the email as email.subject, email.body, etc.  Similarly assuming that your rule has a target table of incident, you simply set current.short_description, etc. to your desired values. 

Pulling a value from the body of the email is pretty standard scripting and putting the Test value and email subject together is just a matter of string concatonation, e.g.

current.short_description = stringFromBody + ", " + email.subject;

where stringFromBody is the text you've parsed out of the email body.

Please let me know if you need help finding the Test: string.

Hope this helps.

:{)

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Jaspal Singh
Mega Patron
Mega Patron

Hi Nitish,

 

You can try using below lines

 

var bodytxt=email.body.test; //stores value 123 from the mail body

current.short_description=bodytxt+' ,'+email.subject;

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.