Hide attachment on an incident record producer

sami_siddiqui
Kilo Explorer

Hi,

 

I am trying to hide the attachment icon on header with below code in Eureka   in an on load client script but it is not hiding the icon.

 

var attachment_header = document.getElementById('header_attachment_list');

attachment_header.style.display='none';


Any help or advise will be highly appreciated.


Sami.

1 ACCEPTED SOLUTION

Can you try hiding the attachment icon using below script



$$('img[title="Attachments..."]')[0].up().up().down().hide();


View solution in original post

20 REPLIES 20

by default manipulating DOM objects is restricted for scoped applications.


Hi Verda,



you can try this to hide the attachment clip


document.getElementById('header_add_attachment').style.display = 'none';


you can try this as well



g_form.disableAttachments();


After long discussions with ServiceNow, here is what needs to be done to hide attachments (beyond disabling) in scoped apps:


1. Go to Access Control (ACL)


2. Go to sys_attachment


3. Operation read


4. Add the following at the top:


5. Add the testingACL function at the button and write your acl rules there.



if(current.table_name == 'your tablesname here"){


      var gr = new GlideRecord('your tablesname here');


      gr.get(current.table_sys_id);      


      gs.log('condition met');


      answer = testingACL(gr);


}



else


answer = 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.indexOf("live_profile") > -1)


  return true;




  // Remove Prefix


  var tableName = current.table_name;


  var invisible_prefix = "ZZ_YY";


  if (tableName.startsWith("ZZ_YY"))


  tableName = tableName.substring(5);




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


  }




function testingACL(gr){


  //add your rules here.....


}}}




you can try this as well



g_form.disableAttachments();