Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Is it possible to display only the most recent additional comment in the notification?

ayano
Giga Guru

When creating a notification in the change request table, if I put ${comments} in the content, the last 3 additional comments will be displayed.

Is it possible to display only the most recent one?

3 REPLIES 3

Ramesh R
Tera Contributor

Hello

Use the below options as per your requirements. 

current.comments.getJournalEntry(1);

var grsjf = new GlideRecord('sys_journal_field');
grsjf.addQuery('element_id',current.sys_id);
grsjf.addQuery('element','comments');
grsjf.orderByDesc('sys_created_on');
grsjf.setLimit(1);
grsjf.query();
if(grsjf.next() ) {
  gs.print(grsjf.value);
}

Community Alums
Not applicable

Hi @ayano ,

you need to use below script to get the latest journal entry from comments field.

 

current.comments.getJournalEntry(1);

Administrators can control the number of journal entries notifications include with the following system property .

 

Property Label Description
glide.email.journal.lines Number of journal entries (Additional comments, Work notes, etc.) included in email notifications (-1 means all). Specifies the number of entries from a journal field (such as Additional comments and Work notes) included in email notifications. A value of -1 includes all journal entries.
  • Type: integer
  • Default value: 3
  • Location: System Properties > Email