In activity logs, need to show the details of attachment addition and deletion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 03:10 AM
I tried below code from wiki.
Table: Attachment [sys_attachment]
Insert: true
Delete: true
When: before
Condition:
Script:
if (current.table_name == 'incident' || current.table_name == 'change_request' || current.table_name == 'problem' || current.table_name == 'problem_task' || current.table_name == 'sc_task' || current.table_name == 'change_task' || current.table_name == 'sc_request' || current.table_name == 'sc_req_item' ) {
addAttachmentAudit();
}
function addAttachmentAudit() {
var attachmentMsg = '';
var gr = new GlideRecord(current.table_name);
if (gr.get(current.table_sys_id)) {
if (current.operation() == 'delete') {
attachmentMsg = 'Attachment deleted: '+current.file_name+' by ' +current.sys_created_by+' on '+gs.nowDateTime();
}
else {
attachmentMsg = 'Attachment added: '+current.file_name+' by ' +current.sys_created_by;
}
gr.u_attachment=attachmentMsg;
gr.update();
}
}
Attachment addition is working properly but deletion is not at all working. Please any suggestions for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 03:35 AM
Hi ,
Check below links:-
Re: Audit sys_attachment table
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
Thanks,
Deepa

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 03:44 AM
Instead of current.table_name use current.sys_class_name to fetch the table name.
Mark Correct if it solved your issue.
Thanks
Rohit