Removing HTML Tags and retaining same tags
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 04:13 PM
To begin with, all help is much appreciated. Thank you!
I have two description fields 1. HTML type 2. String Type
When a user adds content to the HTML description (u_description), I am using the following script to copy the content to the string type description (description) field. Then all the html tags (<p>, </p>, <strong>...) were showing, so I used the code on line 4 to remove the characters that can helped remove the html tags.
Now, the problem is when the data is copied to string field, it takes away some special characters and showing the code format.
[ '&' - & ||| '<' - < ||| '>' - > |||| '+' - + ||| '>' - > ]
I am not good at coding, so can someone please help me figure out how to convert the code of the character back to the actual character value. If possible all above. Ex: 'Sam & Peter' convert to 'Sam & Peter'
(function executeRule(current, previous /*null when async*/) {
var desc = current.u_description;
desc = desc.replace(/<\/?[^>]+(>|$)/g, "");
current.description = desc;
// Add your code here
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 06:21 PM
Hi
Have you tried this function-
GlideSPScriptable().stripHTML(htmlText)
Please mark my answer correcr/helpful, if it helped.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 08:07 PM
take a look at this
