How to print each array element in new line

imran sk
Tera Contributor

Hello experts,

 

I'm querying to sys_approver table and collecting all the approver comments for that particular RITM.

I'm going while loop and adding all comments to array. I'm getting the values in comma separated values which is like paragraph. Instead of getting comments in paragraph I need each comment in new line

How to print each Array element ( comments) in new line 

 

 

Need suggestions here. Thanks in advance ☺️ 

8 REPLIES 8

SumanKumarM
Tera Contributor

Hi Imran,

 

Please try like below,

var ritmCommments= "Please,expedite,the,solution";

gs.addInfoMessage(ritmCommments.split(',').join("\r\n"));

 

Mark helpful, if it works.

 

Brad Bowman
Kilo Patron
Kilo Patron

Add a '\n' either when pushing to the array, or joining the array.

imran sk
Tera Contributor

Hello @Brad Bowman  

Thanks for your support 

 

'\n' not working I tried this before 

You can also retrieve all comments using getJournalEntry(-1), then they'll already be separated

var appGr = new GlideRecord('sysapproval_approver');
if (appGr.get('088813309350c610c7d735018bba1078')){
	gs.print(appGr.comments.getJournalEntry(-1));
}

BradBowman_0-1726513454420.png