How do you get system entries on an activity log

ctsmith
Mega Sage

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!

1 REPLY 1

ctsmith
Mega Sage

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.