How to Add Line Spacing in description After createCaseFromProducer()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 03:03 AM
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.
What I've tried:
1. For plain text (description)
But this doesn’t seem to have any visible effect, possibly because the output is rendered as HTML.
2. For HTML (rich_description)
But this creates a lot of spacing.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 03:56 AM
Hi @GlideFather,
I tried updating the script by adding the variable names in place of the fields, but it's not working.
So when you mention "field," do you mean variables from the Record Producer, or something else?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 05:12 AM - edited 07-11-2025 05:13 AM
@Anusha chandra
Oh I forgot about the field names.. then it would be something like this:
current.description = producer.field1.getDisplayValue() + ' : ' + producer.field1 + '\n\n' + producer.field2.getDisplayValue() + ' : ' + producer.field2 + '\n\n' + producer.field3.getDisplayValue() + ' : ' + producer.field3 + '\n\n' + producer.field4getDisplayValue() + ' : ' + '\n\n'
it will result in:
Field1's Name: Field1's Value
Field2's Name: Field2's Value
Field3's Name: Field3's Value
Field4's Name: Field4's Value
Note I added there the " : " part to separate the field name and the value, but you can use anything like:
- " / "
- " - "
- " | "
One more thing - are the fields always populated? You can write script that would be evaluating the fields and if they are empty, they will not be added to the Description field on the target form.. that would need to be written in the script field as well.
Let me know when you will have chance reviewing it please
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 04:41 AM
Hi @Anusha chandra,
what is the status of your requirement? Have you managed it all?
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2025 05:22 AM
Hi @GlideFather ,
Apologies for delay in response.
I tried the approach which you mentioned but it is not working.
The fields are mandatory so it will always populate. Is there an alternate method to add spacing in the description? Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 05:39 AM
this function "createCaseFromProducer" is an OOTB function.
You can modify that script include function but remember it's an OOTB script and it will impact every HR case which gets generated via record producer as that function is used across all the record producer scripts.
You can try to use after insert business rule on your HR Case table and manipulate the space and update the description field again
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader