- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 02:03 AM
Hi there,
I need to fetch recent additional comments/work notes into email notification. i have used current.comments.getJournalEntry(1) & current.work_notes.getJournalEntry(1) to achieve this. But I'm getting the time frame as well with the additional comments. Can I able to fetch only the comment/work notes ??
Eg: Work notes: This is a test work notes (I required)
Work notes: 2021-02-15 01:22:40 AM PST - User Name (Work notes) This is a test work notes (I don't required)
Solved! Go to Solution.
- Labels:
-
Demand Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 02:35 AM
Hi,
try this
var rec = new GlideRecord('sys_journal_field');
rec.orderByDesc('sys_created_on');
rec.addQuery('name', current.getTableName());
rec.addQuery('element', 'work_notes');
rec.addQuery('element_id', current.sys_id);
rec.setLimit(1);
rec.query();
if(rec.next()){
template.print(rec.value);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 02:35 AM
Hi,
try this
var rec = new GlideRecord('sys_journal_field');
rec.orderByDesc('sys_created_on');
rec.addQuery('name', current.getTableName());
rec.addQuery('element', 'work_notes');
rec.addQuery('element_id', current.sys_id);
rec.setLimit(1);
rec.query();
if(rec.next()){
template.print(rec.value);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 02:46 AM
Thanks, it worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 01:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2024 03:54 AM - edited ‎11-07-2024 03:55 AM
Hi Harish,
If the work notes are not present on the record it will show Undefined. But for this you can check if lastwork is present in the record or not. Like Below code:
var worknote = current.work_notes.getJournalEntry(1);
var worknoteContent = worknote.split("(Work notes)\n");
var lastWorknote = worknoteContent[1];
if(lastWorknote)
{
template.print(lastWorknote );
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 02:11 AM
Hi,
You will get help from below thread
Please mark as correct/helpful, If you find any help