Copy Description (HTML) content to ootb Description (String)

Sam196
Kilo Expert

I had to create a new Description (HTML) field, so the Service Desk agents can use the field with style formatting (bold italics...). However, for reporting purposes across the company we use the ootb Description (String type) field.

I would like to grab the content from the HTML Description to the ootb String type Description field. I understand the styling won't transfer, but I want the full content to be copied over, including the line breaks as it is.

My role doesn't really involve SNOW development, so I am not really sure what to do here, and if possible I like this to be done without using Client-script. Your help is much appreciated! 

I understand the solution might require some coding, but please keep in mind I cannot code, but I can make sense of what is written in a code. Again, thank you in advance!

1 ACCEPTED SOLUTION

This solution contains one Business Rule

When I update the incident's HTML description field, the current contents is copied and populated into the incidents description field.

Take a look at the images and see if it fits your requirements. Let me know if you need any changes.

 

Business rule configuration:

find_real_file.png

Advanced Tab:

find_real_file.png

Script:

(function executeRule(current, previous /*null when async*/) {

	current.description = current.u_html_description; //replace 'u_html_description with your field name for html description'

})(current, previous);

 

Result: (Incidents html field is updated and copied with styling to the Description field)

find_real_file.png

 

It's possible to use a FLOW to do this instead, but I think a business rule is the way to go here and it's very light on the code.

 

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

View solution in original post

9 REPLIES 9

Dan H
Tera Guru

Hi Sam,

On what records do you want to do this and when do you want this copy to happen?

This would be for incident records, and preferably anytime the HTML description field is updated, the latest content needs to sync with the string type description field.

This solution contains one Business Rule

When I update the incident's HTML description field, the current contents is copied and populated into the incidents description field.

Take a look at the images and see if it fits your requirements. Let me know if you need any changes.

 

Business rule configuration:

find_real_file.png

Advanced Tab:

find_real_file.png

Script:

(function executeRule(current, previous /*null when async*/) {

	current.description = current.u_html_description; //replace 'u_html_description with your field name for html description'

})(current, previous);

 

Result: (Incidents html field is updated and copied with styling to the Description field)

find_real_file.png

 

It's possible to use a FLOW to do this instead, but I think a business rule is the way to go here and it's very light on the code.

 

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

Thank you so much Dan, this is really helpful! One question, is there a way to remove the HTML codes from copying over to the string type description field? Just the content between the (<p>) code, in general no html code should be copied to the String field. 

Most of the users who run the reports are non-dev users and they are likely to find any code like content to be "distracting."