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-24-2022 04:15 AM
Hello
sorry for the delay, I have been very busy with other things.
So I created a new business rule a you suggested above, what when testing the result is the same.
This is the business rule:
The code in the script is this one:
(function executeRule(current, previous /*null when async*/) {
if(current.body.indexOf('<table style="padding: 0; margin: 0;" width="100%" 0="">')>-1)
var newBody = current.body.replaceAll('<table style="padding: 0; margin: 0;" width="100%">','');// replace matching string from all positions
current.body = newBody;
})(current, previous);
it is a bit difference from the one you suggested because in your new var body you are still inserting the faulty code 0="" so I did not understand that.
Does this business rule and my code makes sense? or is it wrong and this is why it is not working?
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 06:11 AM
Hi @Damian Martinez
Please write a Before Insert Business Rule on Email Table and use the script below:
BR Details:
Table Name: Email(sys_email)
When: Before insert
Condition: Type is Received
Script:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var regex = /(<([^>]+)>)/ig;
var body = current.body;
var result = body.replace(regex, "");
current.body = result;
})(current, previous);
Screenshot of BR:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke