g_form.disableAttachments(); doesn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2020 11:31 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2020 06:39 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2020 07:44 AM
nope, no errors at all, just doesn't work haha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2020 08:04 PM
Hi,
Please refer above thread.Hope this helps.
Thanks
Sayali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2020 06:26 AM
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