getjournalentry(1) should return only worknotes

VijayKummamuru
Tera Expert
I have script var currentWN = current.work_notes.getJournalEntry(1) currentWN is giving value 2025-04-06 20:59:05 - Abel Tuter (Work notes) Myworknotes I want only My work notes it should not exclude 2025-04-06 20:59:05 - Abel Tuter (Work notes) to store in another variable . #developer @Developer #ITSM@ITIL
4 ACCEPTED SOLUTIONS

J Siva
Tera Sage

Hi @VijayKummamuru 

Try below script. It'll exclude the timestamps.

var rec = new GlideRecord('incident');
rec.get('1682fd87378c1300023d57d543990e2e');
var wrk = rec.work_notes.getJournalEntry(1).toString();
var work_cmts = wrk.split('(Work notes)\n')[1]; // This line will give you only the work notes.
gs.info(work_cmts );

Regards,
Siva

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@VijayKummamuru 

so basically you only want the notes and not the user and date/time

if yes then do this

var dateRE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;
var currentWN = current.work_notes.getJournalEntry(1);
currentWN = currentWN.replace(dateRE, '');	
gs.info(currentWN);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

Vasantharajan N
Giga Sage
Giga Sage

@VijayKummamuru - Just you need to add the .split("(Work notes)\n")[1to get only the work notes added to the ticket.

 

var currentWN = current.work_notes.getJournalEntry(1).split("(Work notes)\n")[1];

 


Thanks & Regards,
Vasanth

View solution in original post

Shivalika
Mega Sage

Hello @VijayKummamuru 

 

var workNotes = current.work_notes.getJournalEntry(1).split("(Work notes)\n")[1];

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

View solution in original post

5 REPLIES 5

Shivalika
Mega Sage

Hello @VijayKummamuru 

 

var workNotes = current.work_notes.getJournalEntry(1).split("(Work notes)\n")[1];

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY