- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2020 04:45 AM
When I change an existing String field (like Description or Resolve Notes) from String to HTML, all the line breaks within existing entries get lost.
What's the best way to prevent that? Do I have to run some update script over the whole table before converting, or is there an easier way?
Solved! Go to Solution.
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2020 05:16 AM
Yes, correct, you have to perform a background script (possibly during the no-peak hours to avoid performance issue) where you will massively update the table using string.replace().
This is the best thing to do for having a good result, give a try and let me know if it works!
Cheers
Alberto

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2020 04:54 AM
Hi,
try the solution suggested by Matt here:
If I have answered your question, please mark my response as correct and/or helpful.
Thank you very much
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2020 05:03 AM
Thanks for your answer. I also found that article, but it's about a UI action for a single entry. I want to switch the whole field type from String to HTML, so I can e.g. enter Resolution Notes both in Rich Text and with embedded pictures.
Does it mean I would have to convert all existing text entries with String.replace() manually on the table? If so, what's the best way to do so with a minimum impact on the overall system performance?
Br

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2020 05:16 AM
Yes, correct, you have to perform a background script (possibly during the no-peak hours to avoid performance issue) where you will massively update the table using string.replace().
This is the best thing to do for having a good result, give a try and let me know if it works!
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2020 05:52 AM
Ok, thank you very much. My script (below) works fine, although the performance was horrible. Not sure if it makes sense to run that in an environment with millions of lines, but if I ever want to switch the field in production, this may be the only way.
grTask = new GlideRecord('task');
grTask.addQuery('close_notes','!=','');
grTask.query();
while (grTask.next()){
grTask.close_notes = grTask.close_notes.replace(/\n/g, '<br></br>');
grTask.update();
}