Business rule to remove code from html email

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 01:34 AM
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.
- Labels:
-
Agent Workspace

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 01:42 AM
Hi,
Is inbound email or the one sent from ServiceNow?
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 01:46 AM
Hello Anil, thanks for your feedback.
this is for inbound emails.
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 02:57 AM
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
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 06:38 AM
Hello Anil,
Thanks so much, I'll give this a try in my dev instance and keep you posted.
Best Regards.