- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2017 07:13 AM
Hi All
This is the script i am using. It gives a undefined at the beginning of the additional comments. Is there a way i can just remove the 1st word?
var comments= current.comments.getJournalEntry(-1);
var com=[];
var na = comments.split("\n\n"); //stores each entry into an array of strings
for (var i = 0; i < na.length; i++) {
com+= na[i] + "<br>";
}
It shows all correct but start with a undefined at beggining. can i do something to chop off that undefined?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2017 08:15 AM
see below new script with more control:
var gr = new GlideRecord('sys_journal_field');
gr.addQuery('element','comments');
gr.addQuery('element_id',current.sys_id);
gr.query();
while(gr.next()){
gs.addInfoMessage('"'+gr.value+'" added by '+ gr.sys_created_by+' at '+gr.sys_created_on);
}
in while loo you can add your logic to create multi line variable and have it assigned to your new field in one go

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2017 07:19 AM
Hi,
It seems like you're making a string, not an array. Hence, try setting:
var com = "";
instead and see if that does the trick.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2017 07:37 AM
Hi Einvald
Still I see the same issue.
undefined12-20-2017 09:36:53 AM - Surya Soni (Additional comments) Test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2017 07:43 AM
Hello soni
why does it say "commentss" here var na1 = commentss.split("\n\n"); Please correct and lets see if it makes any difference.
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2017 07:49 AM
I have edited that post. I was also trying for worknotes. So, i had two. I removed that now