How do you get system entries on an activity log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2017 09:19 AM
I can pull the work notes and public notes from the activities tab on a request or incident form, but how do you get the system entries, i.e., when the system posts that an email has been sent and logs it in the activities tab?
Thanks!
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2017 01:20 PM
Hmmmm.... I think this is what I want:
BR on the sys_email before insert:
(function executeRule(current, previous /*null when async*/) {
var ritmTotask = new GlideRecord('sc_task');
ritmTotask.addQuery('request_item', current.instance);
ritmTotask.query();
while (ritmTotask.next()){
//gs.log("here's something good " + ritmTotask.request_item.getDisplayValue());
var comments = ritmTotask.comments.getJournalEntry(1);
var regex= new RegExp('\n'); // searching for the first line break
var comments2=comments;
var i = comments.search(regex);
if (i>0)
{
// taking everything after the first line break, he-he.
comments2 = comments.substring(i+1, comments.length);
}
//gs.log('pure work notes:'+work_notes2);
//var notes = ritmTotask.comments.getJournalEntry(1);
//var na = notes.split("\n\n");
//for (var i = 0; i < na.length; i++);
var fieldName = "work_notes"; // it can be work notes field or comments field
ritmTotask[fieldName].setJournalEntry("Public notes "+ comments2 + "have successfully been emailed to: " + current.direct);
ritmTotask.update();
//format is as belows:
//objectName[nameOfField].setJournalEntry("value you need to set");
}
})(current, previous);
Regex stuff came from this post from nikita.mironov:
getJournalEntry method - wanna just entry without user and timestamp
So far... working well.