Thursday, January 17, 2013

Hiding SharePoint list field (column) from newform and editform using powershell - SharePoint 2010



Use the below power shell command to hide a particular  column in a sharepoint list from the newform and editform.



$WebUrl = "http://sitecollectionurl"
Write-Host "Opening Web" $WebUrl
$web = Get-SPWeb $WebUrl


$list = $web.Lists["ListName"];



$FieldGuid = New-Object System.Guid("cc9576b6-a166-47c9-bd89-7f47a3237e03");

$Field = $list.Fields[$FieldGuid];

$Field.ShowInNewForm = $false;
$Field.ShowInDisplayForm = $true;
$Field.ShowInEditForm = $false

$Field.Update();

$list.Update();



Here, replace the $WebUrl with your site collection URL, and replace the "ListName" with your SPList name.

And replace the Guid"cc9576b6-a166-47c9-bd89-7f47a3237e03" with the id of the field to be hidden.

For getting the id of the field , you can use 'SharePoint Manager' tool and will be downloaded from here. Its from codeplex and it is free.

No comments:

Post a Comment