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 🙂

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

12 REPLIES 12

mounika32
Tera Contributor

Hi @Samaksh Wani , its not working its returning 0

mounika32_0-1701927993425.png

 

Rahul Talreja
Mega Sage
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);
Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

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...

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

@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 🙂

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande