- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 10:43 PM - edited 11-03-2022 10:48 PM
Hi All,
Is anyone knows how to retrieve value from an HTML Type Field. I have a field on form 'long_description' And I want to print only the text from it.
I tried this one current.getValue('long_description'); but it print all the tag.
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 12:15 AM
Updated script. added space between ""(double quote).
var regex = /( |<([^>]+)>)/ig;
var content =current.getValue("long_description").replace(regex, " ");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 12:18 AM
@Para5 ,
Try the below code:
var regex = /( |<([^>]+)>)/ig;
var content =current.getValue("long_description").replace(regex, " ");
I hope this help.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 10:50 PM
Hello,
Please check the below thread for the answer:-
https://www.servicenow.com/community/developer-forum/how-to-get-raw-text-from-html-field/m-p/2038036
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 12:18 AM
Hello,
Did you try the code I provided you:-
var text = current.long_description.getDisplayValue();
// Replace all <br /> tags with a CRLF
var regX1 = /<br\s\/>/ig;
var text2 = text.replace(regX1, String.fromCharCode(13));
// Replace all remainging HTML tags with ""
var regX2 = /(<([^>]+)>)/ig;
var finalText = text2.replace(regX2, "");
Please mark my answer as correct based on Impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 02:26 AM
Yes I tried but its not working for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 12:01 AM
Hi @Para5 ,
Try the below code, it should work:
var regex = /( |<([^>]+)>)/ig;
var content =current.getValue("long_description").replace(regex, "");
I hope this help.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh