How to keep formatting of description as it is when copying into HTML type Description field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2023 06:13 AM
Hi All,
We have Description field o the incident form and its type is String.
We have another field HTML Description and its type is HTML, where we are copying the Description into HTML Description field using one UI ACTION.
The issue is when we copy the description into the HTML description it looses its formatting.
So is there any way to keep formatting as it is in the HTML Description field.
Could you please refer below snippet.
Thanks you.
- Labels:
-
Service Portfolio Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2023 06:35 AM
Hello @Sonu Parab
Use this :-
string.replace(/\n/g, '<br></br>');
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2023 07:04 AM
Hello @Sonu Parab,
I would just like to enhance @Samaksh Wani answer with carriage returns as well. Because sometimes there are not only new lines, but carriage returns as well.
var description = current.description; // get the String value from the Description field
var htmlDescription = description.replace(/(?:\r\n|\r|\n)/g, '<br>'); // replace new lines carraiage return with <br> tags
current.html_description = htmlDescription; // set the HTML value to the HTML Description field
Kind Regards,
Swarnadeep Nandy