Help with script to hide attachments section in header on form

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2024 04:48 PM
I have a requirement to hide the attachments in the header of a form, as well as the attachment icon (paperclip) when the form loads, and the user isn't a member of a specific group. I already have the group membership portion working to hide form sections and related lists but haven't been able to get the actual attachments to hide. I created a new script just for to see if I can hide the attachments, but still no luck.
Here is what I have currently, which is hiding the paperclip icon as expected, but the actual attachments are still shown. Isolate script in unchecked.
function onLoad() {
g_form.disableAttachments();
document.getElementById('header_attachment').style.display = 'none';
document.getElementById('header_attachment_line').style.display = 'none';
}
When loading form attachments are still displayed, but paperclip is hidden:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2024 01:07 PM
Thankfully we are just about ready to upgrade the rest of the instances as well, so that this shouldn't be an issue any longer,
I did rebuild the ACL directly in the test environment, but it still doesn't work correctly, so I will likely just wait until Xanadu to implement. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2024 06:30 PM - edited ‎12-17-2024 06:31 PM
@Marcel H_ Try this explaining how you can hide and yes dom does not support and you can be in a situation when it would work as admin but for not end user so avoid this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2024 07:09 PM
you are using DOM manipulation which is not recommended
your script will work fine if Isolate Script = False for your onLoad client script
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2024 10:52 AM
@Ankur Bawiskar I would like to control this without DOM manipulation, but I don't think that's possible, correct? Unfortunately, even when making sure that Isolate Script = False the actual attachments aren't hidden, only the attachment icon. Any idea what would cause that script not to work as written?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2024 07:41 PM
it should work and it worked for me
document.getElementById('header_attachment').style.display = 'none';
document.getElementById('header_attachment_line').style.display = 'none';
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader