Hi,
In some cases (such as the "Page Content" field found under the Page Layout columns) it is not possible to delete a field from your list once you have added it. This is because by default some fields have their property set to Sealed="TRUE". Thus, you will not be able to delete the field via the UI, forcing you to use a coding solution. This can be achieved via the following PowerShell script:
Clear-Host
$web = Get-SPWeb http://yourweburl
$list = $web.Lists["YourListName"]
$field = $list.Fields["Page Content"]
$field.AllowDeletion = $true
$field.Sealed = $false
$list.Update()
$field.Delete()
$list.Update()
$web.Dispose()
Keywords
administration
(2)
AJAX
(1)
arrays
(1)
asp
(2)
ASP.NET
(2)
assembly
(2)
automation
(1)
BCS
(1)
bindings
(1)
C#
(10)
cell click
(1)
cell value
(1)
clientside
(2)
connection string
(1)
content types
(2)
CSS
(1)
csv
(1)
datagrid
(2)
delegates
(1)
design patterns
(1)
Dialog
(4)
Dictionary
(1)
domain controller
(1)
domain member
(1)
dropdown list
(2)
endpoints
(1)
enum
(1)
error
(1)
event handlers
(1)
Excel
(1)
exporting
(1)
feature event receiver
(2)
File
(1)
formatting code
(1)
forms
(2)
Function
(1)
gac
(1)
hotfolder
(1)
HTML
(2)
inheritance
(1)
javascript
(4)
keyvalue
(1)
layoutspagebase
(1)
LINQ
(2)
lists
(3)
machine account password
(1)
moss
(1)
namespaces
(1)
ObjectDataSource
(1)
objects
(1)
office
(1)
OleDbConnection
(1)
pairs
(1)
permissions
(1)
pivot
(1)
postback
(1)
powershell
(2)
radconfirm
(1)
registry
(1)
resources
(1)
role definitions
(1)
rowclick
(1)
serialization
(2)
serverside
(4)
sharepoint
(15)
site columns
(3)
snapshot
(1)
SPList
(2)
sql
(1)
sql server
(2)
string
(1)
t-sql
(2)
Telerik
(3)
TFS
(1)
Timer
(1)
timerjob
(1)
transpose
(1)
txt
(2)
update
(1)
VBA
(2)
ViewState
(2)
Visual Studio
(1)
web.config
(1)
webparts
(4)
webservices
(1)
XDocument
(1)
xml
(2)
Showing posts with label site columns. Show all posts
Showing posts with label site columns. Show all posts
Tuesday, March 17, 2015
Monday, October 22, 2012
Finding site column used anywhere in your web application
Little powershell script to find out where your fields are currently being used in the web app
$solutionWebApplication = "http://yourSPurl/"
$fieldTitle = "ActiveConfig" #DisplayName
$fieldGroup = "Custom Columns"
$spAssigment = Start-SPAssignment #Use to dispose SPWeb safely
$spWeb = Get-SPWeb $solutionWebApplication -AssignmentCollection $spAssignment #Get SPWeb Instance
foreach ($field in $web.AvailableFields)
{
if($field.Group -eq $fieldGroup -and $field.Title -eq $fieldTitle)
{
$field.ListsFieldUsedIn() | ForEach-Object {
$web = $site.AllWebs[$_.WebID]
$list = $web.Lists[$_.ListID]
Write-Host "Web:" $web.Title " | List:" $list.Title " | ListUrl:" $list.RootFolder.Url " | StaticName:" $field.StaticName " | FieldID:" $field.ID
}
}
}
$solutionWebApplication = "http://yourSPurl/"
$fieldTitle = "ActiveConfig" #DisplayName
$fieldGroup = "Custom Columns"
$spAssigment = Start-SPAssignment #Use to dispose SPWeb safely
$spWeb = Get-SPWeb $solutionWebApplication -AssignmentCollection $spAssignment #Get SPWeb Instance
foreach ($field in $web.AvailableFields)
{
if($field.Group -eq $fieldGroup -and $field.Title -eq $fieldTitle)
{
$field.ListsFieldUsedIn() | ForEach-Object {
$web = $site.AllWebs[$_.WebID]
$list = $web.Lists[$_.ListID]
Write-Host "Web:" $web.Title " | List:" $list.Title " | ListUrl:" $list.RootFolder.Url " | StaticName:" $field.StaticName " | FieldID:" $field.ID
}
}
}
Tuesday, October 16, 2012
Finding site column used in content type by querying content db
Exception calling "Delete" with "0" argument(s): "Site columns which are included in content types or on lists cannot be deleted. Please remove all instances of this site column pri
or to deleting it."
ughh..
there are myriad approaches to hunt down that damn column, for example by using powershell. here is an alternative, directly querying the content db
or to deleting it."
ughh..
there are myriad approaches to hunt down that damn column, for example by using powershell. here is an alternative, directly querying the content db
SELECT ct.ContentTypeId [ContentType ID] , Definition [ContentType Definition] , ct.DeleteTransactionId [ContentType DeleteTransaction] , ctu.ListId [List GUID using CT] , l.tp_Created [List Creation Date] , tp_DeleteTransactionId [List DeleteTransaction] , tp_FeatureId [Feature GUID] FROM ContentTypeUsage ctu INNER JOIN dbo.Webs w ON ctu.WebId = w.Id INNER JOIN dbo.AllLists l ON ctu.ListId = l.tp_ID INNER JOIN dbo.ContentTypes ct ON ct.ContentTypeId = ctu.ContentTypeId WHERE ct.Definition LIKE '%your column%'
Subscribe to:
Posts (Atom)