current.work_notes.getJournalEntry(-1); returns an empty string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2014 07:53 AM
i tried the code from the documentation:
notes = current.work_notes.getJournalEntry(-1); | |
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]);
- Labels:
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2014 09:36 AM
I reformatted the code to include the appropriate curly brackets. I was successful with this:
var notes = current.work_notes.getJournalEntry(-1);
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]);
}
Let me know if you are still having difficulty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2014 01:41 AM
The code worked fine as it was, omitting the curly brackets is still acceptable syntax.
The problem I'm having is with the 'getJournalEntry' method which returns an ampty string in the 'notes' variable.
I'm trying to search through the 'Activity' of an incident for specific text strings.
- Is the above code segment the right one to use for this?
- How can I do this if the above code doesn't retrieve the text that I need?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2014 06:13 AM
I used your code on my instance and it pulls the work notes just fine for me. The additional comments (comments) field also writes to the activity. Are you sure that what you are looking for was entered in the work notes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2014 07:18 AM
Well, I can't get the method to return anything. I was hoping it was a shortcut to getting the records from 'Journal Entry' table.
So I created this function:
/**
* Gets all journal entries for this incident.
*
* @param incidentSysId
* @returns {String} - each journal entry is separated by a linefeed pair '\n\n'.
*/
function getActivity( incidentSysId )
{
var journalString = "";
var actObject = new GlideRecord('sys_journal_field');
actObject.addQuery('element_id', incidentSysId);
gsLog("incidentSysId: " + incidentSysId);
//actObject.addQuery('element', "comment");
//actObject.addQuery('name', 'task');
actObject.query();
if(actObject.next()) {
gsLog("Journal entry: " + actObject.value);
journalString = actObject.value;
while( actObject.next())
{
journalString += '\n\n' + actObject.value;
}
}
return journalString;
}