Attachment History

BenRamseyer
Kilo Explorer

Is there a way to add the Attachment History to the Activity field? We would like a record of all attach/unattach activity for some of our records.

1 ACCEPTED SOLUTION

mamann
Mega Guru

Here is a business rule we use for Change Requests to log this into the Work Notes
Hope this helps!

Table: sys_attachment
When: After
Insert, Update, Delete are all checked
Condition: current.table_name == "change_request"



var gr = new GlideRecord("change_request");
gr.addQuery("sys_id", current.table_sys_id);
gr.query();
if (gr.next()) {
if (current.operation() == "delete") {
gs.eventQueue("change.attachment.delete", gr, current.file_name, gs.getUserDisplayName());
gr.work_notes = "Attachment: " + current.file_name + " has been deleted by " + gs.getUserDisplayName();
}
else {
gs.eventQueue("change.attachment.insert", gr, current.file_name, gs.getUserDisplayName());
gr.work_notes = "Attachment: " + current.file_name + " has been inserted or updated by " + gs.getUserDisplayName();
}
gr.update();
}


View solution in original post

11 REPLIES 11

CapaJC
ServiceNow Employee
ServiceNow Employee

Attachment history is not tracked in any way that can be added to the activity formatter, but this post asks something similar and links to a wiki article explaining a way to track attachment activity in worknotes:
Attach on activity


CapaJC
ServiceNow Employee
ServiceNow Employee

(sigh) I should try links before I post them. That wiki page doesn't exist anymore. I'll try to find something.


CapaJC
ServiceNow Employee
ServiceNow Employee

Well, shoot. The wiki article was removed because the technique described in it no longer works in current versions. Sorry for the tease.


Thanks for trying! Any other ideas please let me know!