Inbound Action copy body to description

Brian Lancaster
Tera Sage

I have an inbound action where I need to put the email body into the description field.  How can I get it without all the HTML code but not loose the format?

1 ACCEPTED SOLUTION

Brian Lancaster
Tera Sage

I was able to do it with this code.  We where only getting the <br/> as the html in the body.

var emailBody = email.body_html.toString().replace(/<br\/>/g, "\n");
current.description = emailBody;

View solution in original post

5 REPLIES 5

AbhishekGardade
Giga Sage

Hello Brian,

In Inbound action, you can get email body with below code:

current.description = email.body; 

OR

current.description = email.body_text; 

You can open Create Incident inbound action to see the code

Check out this link for complete details:

https://developer.servicenow.com/app.do#!/training/article/app_store_learnv2_automatingapps_madrid_n...

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

Thank you,
Abhishek Gardade

Yes I have done all that but it still put the HTML code into the description as well.  I'm trying to get the body of the email into the description without the HTML code in it.

Use can use this: current.description = email.body_text; 

Thanks,

Abhishek

Thank you,
Abhishek Gardade

Hi Brian,

 

In this case, you can write regular expression to remove HTML tags. Something like below

var htmlString= "<div><h1>Hello World</h1>\n<p>It's me, Mario</p></div>";

var stripedHtml = htmlString.replace(/<[^>]+>/g, '');