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

mounika32
Tera Contributor

how to get the count of lines from multi line text string, I tried below but its returing undeined instead of 2

mounika32_0-1701927088649.png

 

1 ACCEPTED SOLUTION

User might have entered extra 'ENTER' so it is adding extra line at the end.

You can use logic like below:

var current = new GlideRecord('change_request');
current.get('fdbce3f72f323110ae17debcf699b65c');
var itar = current.variables.existing_itar_objects.toString().trim(); // use toString() to change it to string
var lineCount = itar.split('\n').length;
gs.info(lineCount);

View solution in original post

15 REPLIES 15

Hi,

Please try using toString() as suggested above, it should work.