How to remove attachments 'Edit' button in custom table of service portal

kumozhou
Tera Contributor

hi,all

I need to remove the edit button at the top next to the attachment in the form of my custom table from service portal,but also we can download the attachment.

I tried the Client Script with the following method that worked but we can't see and download attached file any more

function onLoad() {

    var attachmentButton = top.document.getElementsByTagName('sp-attachment-button');
    attachmentButton[0].parentNode.hidden = true;
    top.document.getElementsByClassName('sp-attachment-manager')[0].style.display = 'none';

}

And I also tried ACL in sys_attachment,it looks doesn't work.

I wanted to know from where this edit button is coming on the portal form.

Kindly let me know if you have any suggestions?

4 REPLIES 4

Community Alums
Not applicable

Hi @kumozhou ,

You can hide attachments from Service Portal using DOM manipulation but it is not best practice to use DOM manipulation. You can try below code in OnLoad Client script

Table -Your required table name 
UI Type - Mobile/Service Portal
Type - onLoad
Isolate Script - Set it to false/Uncheck

function onLoad() {
var attachmentButton = top.document.getElementsByTagName('sp-attachment-button');
attachmentButton[0].parentNode.hidden = true;
top.document.getElementsByClassName('sp-attachment-manager')[0].style.display = 'none';
}

Mark my answer correct & Helpful, if Applicable.

Thanks,
Sandeep

@Sandeep Dutta

Thank you for your answer.

I have tried the onLoad Client Script . It works that disable attachment icon and edit button.

But I can't see and download the attached file generated from other system connection.

Can you tell me how to remove the edit button and can still download the attachment.

 

@kumozhou 

I have met the same problem. And I use the code below to solve it. Please refer code as below.

function onLoad() {
    var attachmentButton = top.document.getElementsByTagName('sp-attachment-button');
    attachmentButton[0].parentNode.hidden = true;
    var el = top.document.getElementsByClassName('sp-attachment-manager')[0];
    if (el) {
        el.getElementsByTagName('button')[0].style.display = 'none';
    }

 

barry lu
Tera Contributor

Please refer the code as below.

function onLoad() {
    var attachmentButton = top.document.getElementsByTagName('sp-attachment-button');
    attachmentButton[0].parentNode.hidden = true;
    var el = top.document.getElementsByClassName('sp-attachment-manager')[0];
    if (el) {
        el.getElementsByTagName('button')[0].style.display = 'none';
    }
}