We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Adding space when scripting multiple fields to the description field

Tyler Johnson
Kilo Guru

Trying to enter the question with answer on a single line in the description field of incident after the record producer is submitted. The below code i have works to pull the variables in but it puts them all on the same line without any spaces. 

Question 1: Description

Question 2: Description_2

Question 3: contact_phone

//////

current.description += producer.description;  //gives answer for description into incident description

current.description += producer.description_2; //gives answer for description2 into incident description

current.description += producer.contact_phone; //gives answer for contact phone into incident description

 

The above code works by pulling in data but it is all connected without spaces. is there a way to script this so it pulls the data to look like below in description field? Trying to add it on a different line in description but just a space would accomplish the end goal. 

Question 1: Description + 'Question answer'

Question 2: Description_2 + 'Question answer'

Question 3: contact_phone + 'Question answer'

1 ACCEPTED SOLUTION

Sourabh26
Tera Guru

Hi,

 

For adding space you can simply add +' '+ in your code as below.

current.description += '  ' + producer.description;  

current.description += '  ' + producer.description_2; 

 

For new line simply use /n.

 

Mark this as Helpful/Correct, if Applicable.

 

Regards,

Sourabh

View solution in original post

2 REPLIES 2

Sourabh26
Tera Guru

Hi,

 

For adding space you can simply add +' '+ in your code as below.

current.description += '  ' + producer.description;  

current.description += '  ' + producer.description_2; 

 

For new line simply use /n.

 

Mark this as Helpful/Correct, if Applicable.

 

Regards,

Sourabh

Marked as correct thank you Sir.