Tuesday 25 June 2024

servicenow add comments on remove attachment

 show remove attachment

https://www.servicenow.com/community/service-management-forum/how-to-publish-in-work-notes-when-an-attachment-is-deleted/m-p/395206



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();

   }

}


No comments:

Post a Comment