Scenario:
We build a small solution for our client.
Solution had a custom UI for all CRUD operations and client want to block everyone from editing the list using Edit Form.
Solution:
While there can be many ways, considering site is running perfectly in PROD, writing a quick power shell will be enough.
Code:
cls
Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.Powershell
$webUrl = "http://sp2010/siteX"
$web = Get-SPWeb $webUrl
$list = $web.Lists.TryGetList("Tasks")
$fieldDisplayNames = "Status","Priority"
$showFields = $false
$fieldDisplayNames |foreach {
$spfield = $list.Fields[$_]
$spfield.ShowInEditForm = $showFields
$spfield.Update()
}Article:




0 comments:
Post a Comment