Order List Content Types or Solve your "Specified argument was out of the range of valid values.Parameter name: id / value"


You have tried to order the content type list for a list and you are not able to do it. You always receive an error when UniqueContentTypeOrder is set. Take a look at the following steps in order to resolve the issue.

SPFolder folder = list.RootFolder;
IList<SPContentType> contentTypeCollection = new List<SPContentType>();

contentTypeCollection = folder.ContentTypeOrder;
folder.UniqueContentTypeOrder = contentTypeCollection;

in the code above the rootfolder for the list is updated with a new content type collection without the first item. This will update fine the list. the differences:

  • You cannot create the list, add content types and change the order in the same step. First create list, add content types, update and later change the order with a fresh list reference.
  • The contentTypeCollection must be a list qirh the list contentType references, NOT web or site reference.
    • Do not contentTypesCollection.Add(web.ContentTypes[new SPContentTypeId(ct)]);
    • DO contentTypesCollection.Add(list.ContentTypes[new SPContentTypeId(ct)]);


Comments (3)

  1. Rich says:

    Thanks, Carlos! This helped a lot.

  2. Dirk says:

    Thx a lot, great advise

  3. nape says:

    It does not matter how many steps you create the list in. The only important thing is to use the same content types references. If you want to reorder the content type of the folder then you have to use the SPContentType objects from the ContentTypeOrder collection (because these are on the same level) to build up the list for UniqueContentTypeOrder.

Skip to main content