Getting the value of journal entry only

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2011 11:20 AM
Hi Everyone,
I am trying to get journal entry history and put it together as single string. I have tried a few method such as getJournalEntryValue(-1); and separate each line by /n/n, but that method also push the name and the time stamps. I am only interested in the value of each journal entry. I keep trying different way and I keep heading the wall. Is there a way to only get the journal entry values and strip down everything else?! I also tried this, but this only give me the last journal entry value:
var gs = new GlideRecord('sys_journal_field');
gs.addQuery('name','ast_po');
gs.addQuery('element','u_test01');
gs.query();
while (gs.next()){
// gs.print('this should work: ' + gs.value);
current.u_report = gs.value;
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2011 01:43 PM
Querying sys_journal_field should do the trick but you'll need to aggregate all of the results before setting the value. In this script you will only get the last value passed in the while loop.
Should be something like:
var all = "";
while (gs.next()) {
all += gs.value + "\n";
}
current.u_report = all;
Also, you might want to avoid using the variable gs since it already exists in all scripts as a global for glide system methods. For example, in this script you would not be able to use the gs.log() method since you are replacing the global gs with a GlideRecord object.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2011 01:56 PM
Not sure why my brain made this unbelievably more complex than John's...
With some serious Regular Expression pattern matching, it certainly is feasible. However, for those very very rare cases where the user may somehow magically match that pattern it would break.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2011 02:08 PM
John,
Thanks very much. That did the trick, I hope everyone can take advantage of this as it might be quit useful.