How to Add Line Spacing in description After createCaseFromProducer()?

Anusha chandra
Tera Contributor

Hi All,

I'm using the following script to create an HR case from a catalog item producer:
new sn_hr_core.hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);

The description field in the resulting case is a bit too congested. I want to add one line spacing between each line for better readability.

Anushachandra_1-1752227583642.png

 

What I've tried:

1. For plain text (description)

current.description = current.description.replaceAll("\n", "\n\n");

But this doesn’t seem to have any visible effect, possibly because the output is rendered as HTML.

2. For HTML (rich_description)

gs.info("Before Description: " + current.rich_description); var formattedValue = current.rich_description.replace(/<br\s*\/?>/gi, "<p></p>"); current.rich_description = formattedValue;

But this creates a lot of spacing.

Anushachandra_2-1752228092115.png

 

My Questions:

  • What is the correct way to insert spacing (e.g. double line breaks or paragraphs) between lines in rich_description after the case is created?

  • Should I modify the content before or after calling createCaseFromProducer()?

  • Is there a reliable way to check or modify how rich_description is being formatted during the case creation?
    Any suggestions or examples would be greatly appreciated!

    Thanks in advance.




 

10 REPLIES 10

@Anusha chandra 

Did you get a chance to check my above response?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader