- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2017 07:06 AM
Hello,
I'm trying to include the description from a Catalog Item to a Request's Descriptions. The issue is that it's including the HTML
I'm using this to do it:
if (current.order_guide != ''){
var request = new GlideRecord('sc_request');
request.get(current.request);
var itemDescription = current.cat_item.description.getDisplayValue();
itemDescription = itemDescription.replace(/<(?:.|\n)*?>/gm, '').replace(/ /g, ' ');current.description = itemDescription;
The code is working to remove all the <p></p>'s and </li><li>'s. I got line 5 from another forum and I'm not sure exactly how to read it. My issue is that I need all the </li> to create a new line of text. Does anyone know how to tweak line 5 to accomplish this?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2017 08:39 AM
If anyone has a better approach please share but I ended up calling out the HTML tags individually using this list:
itemDescription = itemDescription.replace(/<li>/g, '').replace(/\//g, '').replace(/<p>/g, '').replace(/<ul>/g, '').replace(/<li>/g, '\n').replace(/"/g, '"');
Please note that I remove the initial <li> items and then the /'s by using /\//g and then replace the leftover <li> with \n's. Also, the " had to be replace with " for inches.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2017 08:39 AM
If anyone has a better approach please share but I ended up calling out the HTML tags individually using this list:
itemDescription = itemDescription.replace(/<li>/g, '').replace(/\//g, '').replace(/<p>/g, '').replace(/<ul>/g, '').replace(/<li>/g, '\n').replace(/"/g, '"');
Please note that I remove the initial <li> items and then the /'s by using /\//g and then replace the leftover <li> with \n's. Also, the " had to be replace with " for inches.