Covert the String value to HTML value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2021 05:48 AM
Hi How to convert the String value to HTML value. We are in a need of bringing the description to Service portal widget. Even though the string type of description field has got line break, when the time of it is showed on service portal all the text are displayed in same line without line break.
How could it be sorted out
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2021 05:53 AM
For string to html sample example:
var s = '';
var htmlObject = document.createElement('div'); htmlObject.innerHTML = s; htmlObject.getElementById("myDiv").style.marginTop = something
Try something like this .
Note : Dom is not best practice but if it is unavoidable then you can use this.
Mark my Answer as CORRECT and HELPFUL if it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2021 10:08 AM
I need to do the same, but before warning us about DOM manipulation, the intent is not to do that, we need to grab the contents of the Description field, and then convert into HTML for later being used on a prototype translation web service that supports text with HTML strings.
For example I have on my Description field something like:
* Services are dependent on the organization tied to the incident (typically affected user org)
* Categories are dependent on the service selected.
* Subcategory is dependent on the category selected
Then we want to parse or convert to HTML so we get something like:
<li>Services are dependent on the organization tied to the incident (typically affected user org)</li>
<li>Categories are dependent on the service selected.</li>
<li>Subcategory is dependent on the category selected.</li>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2021 02:10 AM
Have you looked at the functions available in GlideStringUtil?
eg getHTMLValue
https://developer.servicenow.com/dev.do#!/reference/api/rome/server/no-namespace/GlideStringUtilScopedAPI#GSUS-getHTMLValue_S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2023 08:38 AM
How to convert string field values to html field value in ui page