getJournalEntry method - wanna just entry without user and timestamp

nikita_mironov
Kilo Guru
 
1 ACCEPTED SOLUTION

nikita_mironov
Kilo Guru

OK. Answrting myself:
var work_notes = current.work_notes.getJournalEntry(1)
var regex= new RegExp('\n'); // searching for the first line break
var work_notes2=work_notes;
var i = work_notes.search(regex);
if (i>0)
{
// taking everything after the first line break, he-he.
work_notes2 = work_notes.substring(i+1, work_notes.length);
}
gs.log('pure work notes:'+work_notes2);


View solution in original post

8 REPLIES 8

nikita_mironov
Kilo Guru

OK. Answrting myself:
var work_notes = current.work_notes.getJournalEntry(1)
var regex= new RegExp('\n'); // searching for the first line break
var work_notes2=work_notes;
var i = work_notes.search(regex);
if (i>0)
{
// taking everything after the first line break, he-he.
work_notes2 = work_notes.substring(i+1, work_notes.length);
}
gs.log('pure work notes:'+work_notes2);


Thanks this worked like a charm for us!
We were able to fix this on the "Post Knoweldge" action for a problem (the workaround text from OOB simply looked horrible).


Not applicable

as you've seen, it's just a string that you get back.

there's no API to separately retrieve the individual entries, line by line with just the value. There's not even an undocumented way, the contents are inaccessible.

your approach seems to be the only option.


pu
Giga Contributor

Thanks Nikita,

I've just used your regex script for our email templates.

It should really be easier to pull out the latest comments. Maybe ServiceNow will update this in a future release.

I've created a script includes which does a 'template.print' of the cleaned comments for use in email templates / notifications.

Paul