0

I have an SP.ContentTypeCollection for a document library. I'm trying to add a selected one from the site's content types. I also need it to be the new DEFAULT content type for that library.

Thus, I've copied the document library's existing types to a list. Then I want to clear the content types and add my new one FIRST so it becomes default. Then I will add the others I copied.

PROBLEM: I can't find a way to delete one or all of the content types in the collection.

Help? :-) Thanks in advance.

user3549851
  • 31
  • 1
  • 4

1 Answers1

0

You can't delete an element from SP.ContentTypeCollection list. This article provides a code snippet to delete a content type by using client object model , but the code doesn't check if the content type that is being used as you cannot delete a content type that is being used.

The code snippet use the function ContentType.DeleteObject to delete a content type, please be aware of the exceptions in that MSDN link.

Matt
  • 6,010
  • 25
  • 36