How to Check if a Journal field is empty

Eli Guttman
Tera Guru

Hi,

 

I tried to check in a mail script and a business rule if a field of journal type is empty,

 

what is the best way to do it? does it different if i'm using "Journal Input" field?

 

thank you!

1 ACCEPTED SOLUTION

darshanr
Kilo Guru

Hi Eli,



Journal field will always be empty.


You can check with below line:



current.fieldName.getJournalEntry(-1);// It will bring all the journal entries which were added to this



If empty then no entries were added.


Using Journal Fields - ServiceNow Wiki


Please mark answer correct if it was.




Thanks,


Darshan


View solution in original post

5 REPLIES 5

darshanr
Kilo Guru

Hi Eli,



Journal field will always be empty.


You can check with below line:



current.fieldName.getJournalEntry(-1);// It will bring all the journal entries which were added to this



If empty then no entries were added.


Using Journal Fields - ServiceNow Wiki


Please mark answer correct if it was.




Thanks,


Darshan


Thank you.



Another question regarding the journal field - how can is get only the text without the time stamp or the user who provided the comments?


You need to grab the latest journal entry, split it up, and grab the second chunk...



e.g.


var journalStr = current.work_notes.getJournalEntry(1);


var splitJournal = journalStr.split("\n");


var textOnly = splitJournal[1];



JarodM


darshanr
Kilo Guru

Hi Eli,



Every comments done in Journal field gets stored in "sys_journal_field" table.So you can get only text by Quering this table for specific record.



Thanks,


Darshan