- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 11:56 PM
Hello.
I'm migrating CMDB from an external source and need to move a value into an HTML-type field. The issue is that the source data becomes to plain text (from HTML) once I export it in .csv, and then I have special commands in the middle of the data (like '%20' when a blank space is set, and similar).
I tried to transform it back to HTML in transform map but doesn't worked, I even tried to use REGEX to delete the special commands in the middle (as isn't needed that the text will be an HTML, but most that it be understandable) and can't find any proper solution.
Does anyone have any insight into how to proceed?
Thanks in advance.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 11:00 AM - edited 11-27-2024 11:02 AM
Here is how we did it in the business rule, if that helps. We were copying HTML from a field called html_description into the Description field.
current.setValue('description', getFinalText(current.html_description));
function getFinalText(text) {
text = text.replace(/<br\s\/>/ig, String.fromCharCode(13)); //Replace all <br/> tags with a CRLF
text = text.replace(/(<([^>]+)>)/ig, ""); //Replace all remaining HTML tags with ""
text = text.replace(/</g, "<");
text = text.replace(/>/g, ">");
text = text.replace(/"/g, '"');
text = text.replace(/"/g, '"');
text = text.replace(/'/g, "'");
text = text.replace(/@/g, "@");
text = text.replace(/+/g, "+");
text = text.replace(/=/g, "=");
var finalText = text.replace(/&/g, "&");
return finalText;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 10:57 AM
We have cleaned up HTML fields with REGEX before, but it was in a business rule, not a transform map. It should theoretically be the same process, though. What was the issue with your REGEX code? Can you share the code?
I guess as long as all the data is getting moved into the field, you could run a script after the fact to clean it up. Again, you would be using REGEX in that script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 11:00 AM - edited 11-27-2024 11:02 AM
Here is how we did it in the business rule, if that helps. We were copying HTML from a field called html_description into the Description field.
current.setValue('description', getFinalText(current.html_description));
function getFinalText(text) {
text = text.replace(/<br\s\/>/ig, String.fromCharCode(13)); //Replace all <br/> tags with a CRLF
text = text.replace(/(<([^>]+)>)/ig, ""); //Replace all remaining HTML tags with ""
text = text.replace(/</g, "<");
text = text.replace(/>/g, ">");
text = text.replace(/"/g, '"');
text = text.replace(/"/g, '"');
text = text.replace(/'/g, "'");
text = text.replace(/@/g, "@");
text = text.replace(/+/g, "+");
text = text.replace(/=/g, "=");
var finalText = text.replace(/&/g, "&");
return finalText;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 03:29 AM
Hi,
Yes, finally I found a similar option by using a script with .replaceAll() function.
Thanks for your help.