Stripping HTML from a record producer variable to field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015 09:20 AM
Hi all,
We had an enhancement come in to include an HTML variable for our ESS Incident record producer for the detailed description so that clients can embed images for Service Desk to initially assess. We are not planning to change the field on the actual form to HTML as it will mess up thousands of previous records, so we left it blank and the Service Desk needs to manually copy and paste the variable's content into the field. We had tried directly moving it the normal way, but there were a ton of HTML tags.
Is there any way that something can be applied that will automatically strip all of the HTML and populate the description with just the text? We tried to do it but couldn't find a solution.
Any insight would be great if someone has done this before!
Thank you,
Amandah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015 09:25 AM
I should also mention that we're hoping to keep carriage returns somehow - we don't want to see one straight line of content.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015 09:26 AM
Hi Amandah,
Here you go.
var shr = g_form.getValue('description');
var out = shr.replace(/<(?:.|\n)*?>/gm, '');
g_form.setValue('description',out);
At Server Side
var shr = current.u_html;
var out = shr.replace(/<(?:.|\n)*?>/gm, '');
current.description = out;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015 11:13 AM
Hi Sharma,
Thank you for the code - do you happen to know how we can trigger the carriage returns to still function?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015 11:58 AM
Hello Amanda,
We're about to do a similar thing. We have a requirement to "convert the descripion field" to HTML on the incident table.
That way our reporters can include screen images, etc. Our approach is this:
1. Create a new field on the incident table of type HTML, with a name of u_description_html and a label of "Description".
2. Remove the description field from the incident form and add u_description_html.
3. Create and run a script (business rule) to copy the description field to the u_description_html field in each incident record.
Now comes a key part, when you copy the description field, be sure to prepend the text with <pre> and append </pre> to the end of the text. This way the text will appear in the HTML field in a manner similar to a text field.
I hope this helps!