Remove '&#39' from email body inbound email action

Richard Thomas2
Tera Contributor

Hi experts,

I'm trying to remove the apostrophe from an inbound action email body. I've tried various script which have a variation of;

var messageBody = email.body;
messageBody = messageBody.replace(/'/g, ' ');
 
var messageBody = email.body;
messageBody = messageBody.replace(/'/g, ' ');
 
Nothing seems to work. Does anybody have any experience of removing things like this from inbound emails?
 
Thanks as ever
 
Richard
 
 
2 ACCEPTED SOLUTIONS

Hi @Richard Thomas2 

Thanks for the input, try the one below.

var messageBody = email.body_text;
messageBody = messageBody.replaceAll("'", '"').replaceAll("#39;", '"');

 

Please mark my answer helpful and accept as solution if it helped you 👍✔️

Thanks,
Anvesh

View solution in original post

I tried this in Background script, it was working 😀 Keep exploring.

 

AnveshKumarM_0-1695817662999.png

 

Thanks,
Anvesh

View solution in original post

8 REPLIES 8

AnveshKumar M
Tera Sage
Tera Sage

Hi @Richard Thomas2 

Which encoding it is? Can you provide a sample line of it's original text and encoded one?

Thanks,
Anvesh

 

Hi - thank you so much for your reply.

 

So the text looks like this when it's in the incident description. I've removed the actual text in some cases and replaced it with 'xxxxxxx' . I literally just need to remove either the apostrophe or the apostrophe symbol (')

 

The Integration Task 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx#39;Second xxxxxxx -  Bank ' failed at 'Tuesday, 26 September 2023 10:45:10 BST'. For more details about the failure please review the log files available in the execution history within the Integration tasks page.

Hi @Richard Thomas2 

Thanks for the input, try the one below.

var messageBody = email.body_text;
messageBody = messageBody.replaceAll("'", '"').replaceAll("#39;", '"');

 

Please mark my answer helpful and accept as solution if it helped you 👍✔️

Thanks,
Anvesh

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Is &#39' a particular string?

 

If it is one string then try the below:-

 

var body = email.body_text;

var expectedTxt= body.split("&#39") ; // add your line here or keep 4 words

var finaltext= expectedTxt[0]+' '+ expectedTxt[1]
gs.log("finaltext: "+finaltext);

 

Please mark my answer as correct based on Impact.