Friday, April 8, 2016

SharePoint Online: Hide Columns from List using PowerShell-CSOM

Requirement: Hide columns from SharePoint online list. In a project request list, when user fills the form we wanted to hide the "Status" column by default and then have a workflow to populate status of the particular request. Similarly for Edit column as well, but show it only on View form.

SharePoint Online Hide Column from list using PowerShell:
Here is the PowerShell script to hide list columns from SharePoint online list.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Config Parameters
$SiteURL= ""
$FieldName = "Status" #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
    $Field = $List.Fields.GetByTitle($FieldName)

    #Hide the column from New & Edit forms
    Write-host -f Green "List Field hidden Successfully!"
Catch {
    write-host -f Red "Error hiding List Column: " $_.Exception.Message
This hides the specific column from New form and Edit forms of the list!
sharepoint online hide column

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...