Hello,
Just tried to hide SharePoint List fields from New and Edit Forms, wrote a powershell script,
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Config Parameters
$SiteURL= "SharePoint Site URL"
$ListName="ListName"
$FieldName = "ColumnName" #Display Name
#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
Try {
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Cred
#Get the web, List and Field objects
$Web=$Ctx.Web
$Ctx.Load($Web);
$Ctx.ExecuteQuery()
$List=$web.Lists.GetByTitle($ListName)
$Ctx.Load($List);
$Ctx.ExecuteQuery()
$Field = $List.Fields.GetByTitle($FieldName)
$Ctx.Load($Field);
$Ctx.ExecuteQuery()
#Hide the column from New & Edit forms
$Field.SetShowInEditForm($False)
$Ctx.ExecuteQuery()
$Field.SetShowInNewForm($False)
$Ctx.ExecuteQuery()
$Field.UpdateAndPushChanges($True)
$Ctx.ExecuteQuery()
Write-host -f Green "List Field hidden Successfully!"
}
Catch {
write-host -f Red "Error hiding List Column: " $_.Exception.Message
}
Just tried to hide SharePoint List fields from New and Edit Forms, wrote a powershell script,
- Connect to SharePoint
- Load SharePoint List context,
- Get Field to hide from forms
- Use functions to hide field from SharePoint forms.
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Config Parameters
$SiteURL= "SharePoint Site URL"
$ListName="ListName"
$FieldName = "ColumnName" #Display Name
#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
Try {
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Cred
#Get the web, List and Field objects
$Web=$Ctx.Web
$Ctx.Load($Web);
$Ctx.ExecuteQuery()
$List=$web.Lists.GetByTitle($ListName)
$Ctx.Load($List);
$Ctx.ExecuteQuery()
$Field = $List.Fields.GetByTitle($FieldName)
$Ctx.Load($Field);
$Ctx.ExecuteQuery()
#Hide the column from New & Edit forms
$Field.SetShowInEditForm($False)
$Ctx.ExecuteQuery()
$Field.SetShowInNewForm($False)
$Ctx.ExecuteQuery()
$Field.UpdateAndPushChanges($True)
$Ctx.ExecuteQuery()
Write-host -f Green "List Field hidden Successfully!"
}
Catch {
write-host -f Red "Error hiding List Column: " $_.Exception.Message
}