is it possible to Read Data in Comments using glideRecord?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 08:35 AM
Hi All,
I want to read data from the Comments and Work Notes field in Task. The Data is as follows:
I want to read it using the GlideRecord. Can anyone tell me how will I be able to retrieve the data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 08:49 AM
You need to use getJournalentry() function as these are journal fields.
See the post below
current.work_notes.getJournalEntry(-1); returns an empty string

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 09:41 AM
Hi Aashish,
Please find the details below.
3.27 getJournalEntry(int)
Gets either the most recent journal entry or all journal entries.
Parameters: -1: get all journal entries, 1: get the most recent journal entry.
3.27.1 Output Fields
Returns: (Sting) For the most recent entry, returns a sting that contains the field label, timestamp, and user display name of the journal entry. For all journal entries, returns the same information for all journal entries ever entered as a single string with each entry delimited by "\n\n".
3.27.2 Example
var notes = current.work_notes.getJournalEntry(-1); //gets all journal entries as a string where each entry is delimited by '\n\n'
var na = notes.split("\n\n"); //stores each entry into an array of strings
for (var i = 0; i < na.length; i++)
gs.print(na[i]);
Get comments details through glide record
function cdetails(iId)
{
var test= "";
var cm= new GlideRecord('sys_journal_field');
cm.addQuery('element_id', iId);
gs.log("SysId: " + iId);
cm.query();
test= '';
while( cm.next() ) {
test += cm.sys_created_on + ' - ' + cm.sys_created_by + ' (' + cm.element + ')\n' + cm.value + '\n\n';
}
return test;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2017 02:55 AM
We also need to get the specific value of comment details as well but we are doing this on a Service Portal widget.
How would this work on the server side code if for example we just need to get the sys_created_on of the most recent journal entry?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2019 02:10 AM
Is it possible to see the code behind getJournalEntry()? This returns a string but instead I want to take the 4 bits of data from this string and make it into an object. Something like the object below.
{
created: 'x',
created_by: 'y',
content: 'z'
sys_id: '0000000000'
}
Is this possible without using sub string as I'm unsure how long the text will be in the fields?