Need to Display last 3 entries of work notes in one by one order in table format in notification?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 11:56 PM - edited 01-22-2024 01:41 AM
Hi All,
Actually we have notification that will displaying the worknotes as one column in table format in notification like below
and the email script to display this is below
So now my concern was the work notes has needs be display in proper order one by one like this
Please help me to complete this
Thanks
Ramu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 12:56 AM
this is the sample code to get latest 3 values.
please enhance it by adding code in your email script and use proper html table tags
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var fieldName = 'work_notes';
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(3);
rec.query();
while(rec.next()){
template.print(rec.value);
}
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 01:02 AM
Thanks for the response
Actually i am not sure where i need to do changes in my script , so my email script was , actually this is we create for tabular format
Can you please help me to where i have to replace the code?
Thanks
Ramu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 01:08 AM
I already shared the logic on how to fetch 3 latest work notes
Now the next part is what you can enhance from your side.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 01:27 AM - edited 01-22-2024 01:41 AM
Actually my script also is fine but it display the work notes not in a proper order, so my concern is like need to display those worknotes in proper order like this order