how to get the count of lines from multi line text string in servicenow

mounika32
Tera Contributor
 
1 ACCEPTED SOLUTION

Please close this question by marking my response as correct solution so that it will be helpful for future users to find correct solution.

Happy Learning 🙂

View solution in original post

12 REPLIES 12

mounika32
Tera Contributor

Hi @Community Alums , its not working its returning 0

mounika32_0-1701927993425.png

 

Rahul Talreja
Mega Sage

Hi @mounika32 ,

Try Below script - 

var chatHistory = "Line 1\nLine 2\nLine 3\nLine 4";
var lines = chatHistory.split('\n');
var lineCount = lines.length;
gs.info(lineCount);

Anil Lande
Kilo Patron

Hi,

I hope answer provided on another question resolved your issue:

https://www.servicenow.com/community/developer-forum/how-to-get-the-count-of-lines-from-multi-line-t...

 

 

@Anil Lande , yes 

Please close this question by marking my response as correct solution so that it will be helpful for future users to find correct solution.

Happy Learning 🙂