g_form.disableAttachments(); doesn't work

yundlu316
Kilo Guru

Our team is working in New York and want to hide the Attachment button on a record producer if you don't have a certain role.  We have a catalog client script onLoad that has:

  g_form.disableAttachments();

if you do not have the "admin" role.  However, that does absolutely nothing.  We are developing in a scoped application and have read that disableAttachments only works in global.  Is this true?  We've recreated the catalog client script in global and it still does nothing.  Is this a bug or are we doing something wrong?

As a workaround, we're using this:

function onLoad() {
        var attachmentButton = top.document.getElementsByTagName("sp-attachment-button");
        //console.log(attachmentButton);
        attachmentButton[0].parentNode.hidden = true;
}

However, it's not 100% ideal because the footer that the button is in is still visible and when the page loads, you see the attachment button for a split second before it disappears.  Any thoughts or suggestions?

8 REPLIES 8

Hi,

any browser console you are getting?

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

nope, no errors at all, just doesn't work haha

sayali udgave
Kilo Guru

Hi,

 

https://community.servicenow.com/community?id=community_question&sys_id=1a121721db101fc01dcaf3231f96...

 

Please refer above thread.Hope this helps.

 

 

Thanks

Sayali

 

 

Hi, we've looked over this and tried their suggestions without any success when it comes to disableAttachments().  We "solved" for it by doing this:

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

but we're still confused why disableAttachments() won't work on the Record Producer when viewed in Service Portal