
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2017 08:09 PM
We are trying to create a widget for Service Portal in which we need to evaluate the sys_created_on, created_by and value of the most recent comment on an incident. So far we've only come up with the following:
data.recentcomment = gr.comments.getJournalEntry(1);
But this outputs a single line containing all the values as a string.
We are looking into a way to use glide record on the journal entry and get the individual values for the sys_created_on, created_by and comment value itself on the Server Side Script and pass it on a variable.
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2017 12:35 AM
Thanks everyone, upon further research I was able to extract the individual comment data values using the following code:
// Check Latest Comment
var cm = new GlideRecord('sys_journal_field');
cm.addQuery('element_id', data.sys_id);
cm.addQuery('name', 'task');
cm.addQuery('element', 'comments');
cm.orderByDesc('sys_created_on');
cm.setLimit(1);
cm.query();
while (cm.next()) {
data.cmvalue = cm.value.toString();
data.cmdate = cm.sys_created_on.toString();
data.cmby = cm.sys_created_by.toString();
}
Now you can just use data.cmvalue, data.cmby and data.cmdate anywhere on your code or output it on HTML.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2017 08:57 PM
HI Jimboy,
You may use 'sys_journal_field' table which stores all the comments/journal entries.
Hope this helps. Mark the answer as correct/helpful based on impact.
Thanks
Antin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2017 12:34 AM
HI Jimboy,
You can check with the below script.
var comment = new GlideRecord("sys_journal_field");
comment.orderBy('sys_created_on');
comment.query();
if(comment.next()) {
return comment.sys_created_on; //First comment added Timestamp
}//end of journal Query
Instead of OrderBy you can use 'OrderByDesc" to get the latest comment
Regards,
Sujata
Mark the answer as correct/helpful based on impact.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2017 12:23 AM
This returned no value. We are adding this on a widget that is to be placed on the ticket page on Service Portal for reference.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2017 12:35 AM
Thanks everyone, upon further research I was able to extract the individual comment data values using the following code:
// Check Latest Comment
var cm = new GlideRecord('sys_journal_field');
cm.addQuery('element_id', data.sys_id);
cm.addQuery('name', 'task');
cm.addQuery('element', 'comments');
cm.orderByDesc('sys_created_on');
cm.setLimit(1);
cm.query();
while (cm.next()) {
data.cmvalue = cm.value.toString();
data.cmdate = cm.sys_created_on.toString();
data.cmby = cm.sys_created_by.toString();
}
Now you can just use data.cmvalue, data.cmby and data.cmdate anywhere on your code or output it on HTML.