Sharepoint 2010 Content Type Query Usage Locations
When attempting to delete a content type you may recieve the error: "The content type is in use."
The following steps can be taken to determine where (the url) the content type continues to maintain a reference in.
From the url you can visit the item and delete the item (removing the dependency on the content type).
NOTE: If you have items in the recycle bin, GetUsages() may report a false "0" count.
The following steps can be taken to determine where (the url) the content type continues to maintain a reference in.
From the url you can visit the item and delete the item (removing the dependency on the content type).
NOTE: If you have items in the recycle bin, GetUsages() may report a false "0" count.
PS C:\Users\spsetup> $ct1 = $web.ContentTypes["HowToPage"]
PS C:\Users\spsetup> $ct1.ToString()
Microsoft.SharePoint.SPContentType
PS C:\Users\spsetup> $web.ContentTypes.Delete($ct1.Id)
Exception calling "Delete" with "1" argument(s): "The content type is in use."
At line:1 char:25
+ $web.ContentTypes.Delete <<<< ($ct1.Id)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
PS C:\Users\spsetup> $usages = [Microsoft.Sharepoint.SPContentTypeUsage]::GetUsages($ct1)
PS C:\Users\spsetup> $usages.ToString()
System.Collections.Generic.List`1[Microsoft.SharePoint.SPContentTypeUsage]
PS C:\Users\spsetup> $usages.Count
1
PS C:\Users\spsetup> write $usages
Id Url IsUrlToList
-- --- -----------
0x010109009FEDEAD31D814... /Documents True
Comments
Post a Comment