The CreatorCon Call for Content is officially open! Get started here.

How to Make Attachment as Readonly

pradeepgupta
Giga Expert

Hi All,

Requirement is to make Attachment as read only based on condition. A logged in user can view the attachment, download the attachment however should not able   to rename, delete or modify.

Please help me to achieve this.

3 REPLIES 3

Mike Allen
Mega Sage

There are ACLs on the sys_attachment table.   Just restrict the ACLs to read and create (so they can add attachments), and give delete and write to the elevated users that can do this.


Hi Mike I have noticed that the attachments in our instance is only visible to the person that attached the file. I want the attachments to at least be able to be read by the approvers. I know that it is lying somewhere in the sys_attachment table, but I am not quite sure what to change. Here is the code that I see under the READ ACL for the sys attachment table:


getAttachmentReadAnswer();



      function getAttachmentReadAnswer() {


              if (current.table_name.nil())


                      return true;



              // If the attachment is from live feed,


              // grant it the read access


              if (current.table_name == 'live_profile')


                      return true;



              // Remove Prefix


              var tableName = current.table_name;


              var invisible_prefix = "invisible.";


              if (tableName.startsWith("invisible."))


                      tableName = tableName.substring(10);



              var parentRecord = new GlideRecord(tableName);



              parentRecord.setWorkflow(false);


              if (!parentRecord.get(current.table_sys_id)) {


                      if (current.sys_created_by.equals(gs.getUserName()))


                              return true;


                      return false;


              }



              return parentRecord.canRead();


      }



Any help that you can provide would be most appreciative.