Business rule to remove code from html email

Damian Martinez
Mega Sage

Hello Community,
does somebody have experience with java script?
I need to create a business rule that removes the following line from html code in emails:
<table style="padding: 0; margin: 0;" 0="" width="100%">
This line of code is causing email in the agent workspace not to render properly.
I don't have experience with java script.
your help is appreciate it.

Best Regard.

 

6 REPLIES 6

Anil Lande
Kilo Patron

Hi,

Is inbound email or the one sent from ServiceNow?

 

Thanks,

Anil Lande

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hello Anil, thanks for your feedback.
this is for inbound emails.
Regards

Hi,

You can create before insert BR on sys_email table with highest order. Make sure will execute for particular scenario so that other emails will not be affected.

You can use below logic in script section:

if(current.body.indexOf('<table style="padding: 0; margin: 0;" 0="" width="100%">')>-1){
var newBody = current.body.replaceAll('<table style="padding: 0; margin: 0;" 0="" width="100%">','');// replace matching string from all positions
current.body = newBody;

//newBody = replaceAll('<table style="padding: 0; margin: 0;" 0="" width="100%">','<table>'); 
//current.body = newBody;

}

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hello Anil,
Thanks so much, I'll give this a try in my dev instance and keep you posted.

Best Regards.