- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2018 12:41 AM
Hi All,
From the Knowledge table, I want to get the content from the field text. The content in the field is of type HTML.
I do not want the entire contents to be retrieved, I'm interested in only a part of it.
If I use the GlideElement getHTMLValue(maxChars) method, it returns even the HTML tags.
Like why is this happening. How can I retrieve only the text having 20 characters.
Here is my code
function getTextContents(query) {
var textContents = [];
var gr = new GlideRecord('kb_knowledge');
gr.addEncodedQuery(query);
gr.query();
while (gr.next()) {
textContents.push (gr.text.getHTMLValue(20));
}
return textContents;
}
Thanks in Advance
Balu
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2018 02:17 AM
Hi Balu,
Please use following.
gr.text.getHTMLValue(20).replace(/<\/?[^>]+(>|$)/g, "");
Thanks
harshad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2018 03:33 AM
Hi Balu,
Thank you for the update.
Appreciate if you mark the post as correct so it gets listed in solved so other can have s help form this if required.
Thanks again for sharing an update.
Best regards,
Harshad