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

Narendra Kota
Mega Sage

Hi,

You need to extract this from those body and subject line as:

var bod = email.body; // body text is, Test:123
bod = bod.split(":");
var str = bod[1]; // here you will get 123

var subj = email.subject; //subject text is, Email Subject 
var text = str + ',' + ' subj';

//and, set it as
current.short_description = text;

Hope this helps.
Mark helpful or correct based on impact.

Thanks.