Hiding a ListField in NewForm/EditForm in Sharepoint
Hiding a Field can be useful if you don’t want your Users to be able to edit a specific field. Mattias Karlsson, a friend of mine, describes a step-by-step on achieving this on his blog. In this Post, I’m going to describe how to do it through PowerShell. First make a connection to the specific Field, then simply set the ShowInNewForm and ShowInEditForm properties to $false. This will hide the fields from the User when the user is trying to create or edit a List Item.
The image below shows the list that I’m going to edit. I will remove the UserField so that Users editing Items in this List won’t be able to edit the UserField
We can hide the fields through a simple function.
function Hide-SPField([string]$url, [string]$List, [string]$Field) {
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$SPSite = New-Object Microsoft.SharePoint.SPSite($url)
$OpenWeb = $SPSite.OpenWeb()
$OpenList = $OpenWeb.Lists[$List]
$OpenField = $OpenList.Fields[$Field]
$OpenField.ShowInNewForm = $False
$OpenField.ShowInEditForm = $False
$OpenField.Update()
$SPSite.Dispose()
$OpenWeb.Dispose()
}
Hide-SPField -url http://moss -List "My Custom List" -Field "UserField"
Now, when the user clicks on New Item or Edit Item, the UserField won’t be visible.
[?]


Excellente! Thanks a lot for this simple yet great way of hiding fields on edit form and new form.
Do you know any way to add more fields to Document library “Group By” option?
Nice script, thanks.
I found that it was necessary to add .PushChangesToList=true
Works great, thanks Niklas.
I’m having a list with 2 content types. However, running the script it only applies to the default content type. Do you know how to apply it to all content types on the list? Or maybe be able to select each content type and apply the script?
Perfect. Thanks