Cls
Add-PSSnapin "Microsoft.Sharepoint.Powershell"
$web=
Get-SPWeb -Identity
"http://test.dev/sites/Wftest"
$ls=$web.Lists.TryGetList("test");
$flds=$ls.Fields["CustID"]
$flds.ReadOnlyField=$true
$flds.Update();
Note: If ReadOnlyField =TRUE, the field is not displayed in New or Edit forms
ReadOnly to TRUE hides the field from Site Settings pages for managing site columns and content types. Setting the Hidden attribute to TRUE completely hides the field from the UI.
Default ReadOnlyField value is set to false.
Best Practice is to Use
$flds.ShowInDisplayForm=$false;
$flds.ShowInEditForm=$false;
Updated Powershell script would be.........
Cls
Add-PSSnapin "Microsoft.Sharepoint.Powershell"
$web= Get-SPWeb -Identity "http://test.dev/sites/Wftest"
$ls=$web.Lists.TryGetList("test");
$flds=$ls.Fields["CustID"]
$flds.ShowInDisplayForm=$false;
$flds.ShowInEditForm=$false;
$flds.Update();
No comments:
Post a Comment