Get Complete Activity Log (Work Notes & Comments) from a record via script
Import
·
Oct 16, 2021
·
article
This Article helps you in getting the complete activity logs from a record that includes work notes & comments with a command. You can use this in different ways on tables that are extended to Task i.e. Incident, RITM etc.,
Sample Code:
var j = new GlideSPScriptable().getStream("incident", "<record sysid>");
for(var m = 0; m < j.entries.length; m ++) {
gs.print(j.entries[m].field_label + " - " + j.entries[m].value + " - Added By " + j.entries[m].login_name + " - On " + j.entries[m].sys_created_on.toString());
}
Sample Result
Additional comments - Followup on my Incident- Added By David Miller - On 2020-12-12 07:11:27
Additional comments - When my ticket is going to be resolved - Added By David Miller - On 2020-12-12 07:11:14
Work notes - more information from security team- Added By System Administrator - On 2020-12-11 13:41:10
To see complete activity log
var j = new GlideSPScriptable().getStream("incident", "<record sysid>");
gs.print(JSON.stringify(j));
Please bookmark & mark it as helpful if it solves your issue.
Thanks,
Narsing
View original source
https://www.servicenow.com/community/now-platform-articles/get-complete-activity-log-work-notes-comments-from-a-record-via/ta-p/2316746