SubPointSolutions / spmeta2

SharePoint artifact provision for .NET platform. Supports SharePoint Online, SharePoint 2019, 2016 and 2013 via CSOM/SSOM.
http://subpointsolutions.com/spmeta2
134 stars 56 forks source link

Child content type with IdNumberValue fails #1072

Closed ghost closed 7 years ago

ghost commented 7 years ago

Adding two content types, parent and child. Parent succeeds, child fails, with a COM exception indicating a duplicate ID: 0x80070055

version 1.2.130, SSOM, SharePoint 2016.

VERBOSE: Processing: [1/10] - [10%] - [ContentTypeDefinitionExtension] [Name:[Extract] Id:[2b56829b-0a0d-45d1-9763-606582bf0f4f] IdNumberValue:[]] VERBOSE: Processing: [2/10] - [20%] - [ContentTypeDefinitionExtension] [Name:[Child Extract] Id:[00000000-0000-0000-0000-000000000000] IdNumberValue:[01]]

// the ...4977 content type is another custom content type. 
public static ContentTypeDefinitionExtension IdentityExtract => new ContentTypeDefinitionExtension
{
  ParentContentTypeId = "0x010100e904ae844b904d9ab9a0e75ae5ba4977",
  Id = new Guid("2b56829b0a0d45d19763606582bf0f4f"),
  Name = "Extract",
  Group = "Extract Content Types",
};

public static ContentTypeDefinitionExtension ChildExtract => new ContentTypeDefinitionExtension
{
  ParentContentTypeId = "0x010100e904ae844b904d9ab9a0e75ae5ba4977002b56829b0a0d45d19763606582bf0f4f",
  IdNumberValue = "01",
  Name = "Child Extract",
  Group = "Extract Content Types",
};
// we define this extension as handler in provision service
public class ContentTypeExtensionModelHandler : ContentTypeModelHandler
{
  public override Type TargetType
  {
    get { return typeof(ContentTypeDefinitionExtension); }
  }
}
ghost commented 7 years ago

This issue was a SharePoint bug. Previously we had deployed content types with feature XML. They were removed from the UI / object model, but still in the database. Apparently an issue since SP2007, still not fixed 😭

SubPointSupport commented 7 years ago

Nearly "as always SharePoint feature" case :)