If you have been around SharePoint for some time you probably know that you can control whether your lists allow for attachments from the list settings page > Advanced Settings. This has been great when building solutions and preventing users from inadvertently uploading files and attaching them to list items when they shouldn’t.

Attachment Settings for a ListAttachment Settings for a List

Today I needed to do this for the first time in a long time and come to my surprise that there is a bit of a hiccup in how this works in the new modern experience. I do not know if it has always been like this but I noticed but I noticed it today. In the classic experience when you disable attachments on a list it hides the control from the New, Edit and Display form, in modern it only appears to hide it from the New form. If you attempt to upload an attachment from the Edit or Display form you will be greeted with the following message:

Attachment Error MessageAttachment Error Message

Upon research, “Googling,” I found out that other people have run into this issue and were going as far as customizing forms with Power Apps to simply hide the attachments control on the forms, which is ridiculous to me.

After some digging around in Dev Tools to see if I could figure out from there, I couldn’t, I started thinking about the other ways you could hide columns on a form. This led me to remember that if you set a columns status to hidden on the content type that it hides the control from the form. Sadly though, you are unable to change that setting through the GUI so off to PowerShell we went.

powershell
Connect-PnPOnline https://anthonyepoulin.sharepoint.com/
$list = Get-PnPList -Identity "Test List for Attachments"
$field = Get-PnPField -List $list -Identity "Attachments"
$field.Hidden = $true
$field.Update()
$field.Context.ExecuteQuery()

The PowerShell above leverages the PnP PowerShell module and we are simply targeting the list we want to hide the attachments control on all forms and then setting the Hidden property to false. Upon doing this the attachment control is hidden from the Edit and Display forms now too.

Attachment field is hidden on the formAttachment field is hidden on the form

It is a tad bit annoying that you have to fallback to running some PowerShell to hide the attachments control on the Edit and Display forms when you use to be able to do it from the GUI in the classic experience but at least there is still a way. I hope this helps anyone else who runs into this little annoyance like I did.

AaaS - Anthony as a Service