- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 07:54 AM
when notification is getting triggered, then content i.e. Additional comment is not coming, only work notes is coming. What should be checked?
Notification which user received:
Notification (what it will contain):
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 08:39 AM
Hi @shubhi211 ,
you can use email script and include that email script in email body.
Email script will fetch the latest comments and print it
Something like this
var fieldName = 'comments'; var rec = new GlideRecord('sys_journal_field'); rec.orderByDesc('sys_created_on'); rec.addQuery('name', current.getTableName()); rec.addQuery('element', fieldName); rec.addQuery('element_id', current.sys_id); rec.setLimit(1); rec.query(); if(rec.next()){ template.print("Latest comments: "+ rec.value); }
If my response helped please mark it correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 08:48 AM
Hi @shubhi211 ,
In order to print the comments and work notes, please try the below in notification email script:
(function runMailScript(current, template, email, email_action, event) {
template.print('WorkNotes: ' + current.work_notes.getJournalEntry(1));
template.print('Comments: ' + current.comments.getJournalEntry(1));
})(current, template, email, email_action, event);
Mark this as Helpful / Accept the Solution if this helps
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 09:12 AM
One question team,
We should not use: ${comments_and_work_notes} ??????
as using ${comments_and_work_notes} the comments should get attached to the email but it is not getting attached to the??? why so
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 01:22 AM
Hi @shubhi211 ,
This is the email script code.
So, you create a notification email script under table [sys_script_email]
Once created that need to be called in the notification as below:
${mail_script:notificationscriptName}
Check the below doc for details: Notification Email Scripts
I am not able to find the email script named 'comments_and_work_notes' in PDI so looks like it is custom. Please provide the code of it to debug further. In the meanwhile, you can try the above scripts and call it in notification and test it.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 02:44 AM - edited 07-25-2024 02:48 AM
Hi @shubhi211 ,
Thanks for providing reference:
I have tested it and it is working fine. Please take a look below:
In the notification, defined as below:
In your incident, please check if there are work notes or comments present or not.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 08:19 PM - edited 08-19-2024 08:19 PM
Solution provided by ServiceNow team:
As work notes and additional comments at a time, in email properties you have mentioned to append on 1 journal entry, that is it is taking only lated journal entry i.e work notes and not appending comments in notification
Solution Proposed:
-- So if there two journal entries at a time, if you want include two entries in notification you can update "Number of journal entries" in email properties.
Email properties
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 08:25 AM
@shubhi211 : Please share more information on the notification that you have configured to check further.
Regards,
Priyanka Salunke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 08:38 AM
what else to share??
Issue is only additional comment is not getting triggered, but Work notes are getting triggered correctly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 08:39 AM
Hi @shubhi211 ,
you can use email script and include that email script in email body.
Email script will fetch the latest comments and print it
Something like this
var fieldName = 'comments'; var rec = new GlideRecord('sys_journal_field'); rec.orderByDesc('sys_created_on'); rec.addQuery('name', current.getTableName()); rec.addQuery('element', fieldName); rec.addQuery('element_id', current.sys_id); rec.setLimit(1); rec.query(); if(rec.next()){ template.print("Latest comments: "+ rec.value); }
If my response helped please mark it correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 08:48 AM
Hi @shubhi211 ,
In order to print the comments and work notes, please try the below in notification email script:
(function runMailScript(current, template, email, email_action, event) {
template.print('WorkNotes: ' + current.work_notes.getJournalEntry(1));
template.print('Comments: ' + current.comments.getJournalEntry(1));
})(current, template, email, email_action, event);
Mark this as Helpful / Accept the Solution if this helps
Mark this as Helpful / Accept the Solution if this helps.