- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2015 04:32 PM
Hi ServiceNow Community,
I am having some scripting issues attempting to copy the following:
I created a new field within the Change Management Module called "Change Description". The reason for this is that I wanted to have the change description field HTML but not impact the description field that sits across the task table.
What I would like to do is copy the text content from the Change Description field "u_change_description_html" into the standard "description" field.
I have attempted business rules and client scripts, but nothing I have tried seemed to help. I did see a few comments about this in other forums however, nothing seemed to work for me.
If anyone has any suggestions or has already created a script for this it would be greatly appreciated.
Regards,
Rob
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 12:03 AM
use regular expression to remove the html tags like below,
copy the below code and paste it in the business rules.
var text = current.u_change_description_html.toString();
var regX = /(<([^>]+)>)/ig;
var finalText = text.replace(regX, " ");
current.description = finalText;
try and lemme know if any issues
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2015 11:26 PM
Try something like following code this in Business rule
var str = current.u_change_description_html;
str = str.substring(str.indexOf('>##'),str.indexOf('##<'));
current.description = str;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2015 11:32 PM
I would like it to remove all HTML tags not just the #..
eg. remove the <p> and styles and font-size etc.. all HTML related tags and convert it to plain text
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2015 11:42 PM
Well you could do that too by adding or subtracting character sequence .
str = str.substring(str.indexOf('>##')+1,str.indexOf('##<')+2);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2015 11:53 PM
Hi @rob_blakey,
Write a onSubmit client script with the following code. Please let me know the outcome.
function onSubmit() {
//Type appropriate comment here, and begin script below
var des = g_form.getValue('u_change_description_html');
var StrippedString = des.replace(/(<([^>]+)>)/ig,"");
g_form.setValue('description',StrippedString);
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2018 12:06 AM
If there are symbols, tags will still be displayed.