- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 04:50 PM
Hi all,
I have as a requirement to update the work notes every time a file is attached or deleted, I have researched and there are events such as attachment.read and attachment.deleted that can help me to solve it.
If someone can help me to call them from a business rule I would appreciate it very much.
Greetings to all.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 05:41 PM
Every Time a file is deleted from the record , you will be losing the access to the file name by the time the event attachment.delete is called as the file donot exist in the database
You can use a BR for this requirement on the attachment table (sys_attachment) and you can log that in the ticket as per your requirement
Create a Business Rule on the "sys_attachment" table. This will log a work note in the record that it was removed.
-Name: "Delete Attachment - Update Record"
-When: Before
-Delete: true
updateRecordForAttachment();// calling this function before deleting
function updateRecordForAttachment(){
var gr = new GlideRecord(current.table_name);//if you want only for a particular table you can even add a condition in BR to run only for that table
if(gr.get(current.table_sys_id)){
gr.work_notes = "Attachment: " + current.file_name + " has been removed.";
gr.update();
}
}
Hope this helps
Mark this response as correct if that really helps
Thanks,
Siva

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 05:41 PM
Every Time a file is deleted from the record , you will be losing the access to the file name by the time the event attachment.delete is called as the file donot exist in the database
You can use a BR for this requirement on the attachment table (sys_attachment) and you can log that in the ticket as per your requirement
Create a Business Rule on the "sys_attachment" table. This will log a work note in the record that it was removed.
-Name: "Delete Attachment - Update Record"
-When: Before
-Delete: true
updateRecordForAttachment();// calling this function before deleting
function updateRecordForAttachment(){
var gr = new GlideRecord(current.table_name);//if you want only for a particular table you can even add a condition in BR to run only for that table
if(gr.get(current.table_sys_id)){
gr.work_notes = "Attachment: " + current.file_name + " has been removed.";
gr.update();
}
}
Hope this helps
Mark this response as correct if that really helps
Thanks,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2019 09:45 AM
Hello Siva Kalyan Chatakonda,
Your help has helped me a lot to solve my request.
I appreciate your time and dedication to the colleagues we just started.
Greetings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2024 06:14 AM
Hi
Using this code I am deleting the attachment on Case record but I want to put message in Additional comments that "filename + "delete an attachment " in Additional Comments after delete the attachment
Can you please help on this.