Copying a field content to another

rob_blakey
Tera Expert

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

1 ACCEPTED SOLUTION

salemsap
Tera Expert

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


View solution in original post

13 REPLIES 13

salemsap
Tera Expert

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


Hey Alex,



This seemed to work however the output file is as per the below. As you can see we still get " " other than that it worked like a treat



"& nbsp;"


  # This is a Test Change #  


"& nbsp;"


How to solve it? 

Have you made any improvement?

If there are symbols, tags will still be displayed.