How to print each array element in new line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 10:46 AM
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 ☺️
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 10:54 AM
Hi Imran,
Please try like below,
var ritmCommments= "Please,expedite,the,solution";
gs.addInfoMessage(ritmCommments.split(',').join("\r\n"));
Mark helpful, if it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 11:19 AM
Add a '\n' either when pushing to the array, or joining the array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 11:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 12:04 PM
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));
}