Question

I have a Library containing a Document Set.

  • The Document Set is of content type "MyDocumentsSet" inheriting directly from native ct "DocumentsSet" -- that's not really relevant here.
  • I have configured the library so that the default ct is "MyDocument", inheriting directly from native ct "Document" ( 0x0101 ).

MyDocument's content type id is : 0x0101005270FFF03AD51B41B40BB981DFDFEAA0.

Yet when I drag&drop a document into the Documents Set and do a litle JSOM magic to retrieve its ContentTypeId, I see that it is :

0x0101005270FFF03AD51B41B40BB981DFDFEAA00076B8F482D790F74B8A27DC2811D17D0B

What it would normally mean in SharePoint is that this document uses a content type inheriting from MyDocument.

The thing is : I have no idea why SharePoint creates a child ct.

Additionally, when I add the Content Type in the default view of the library, it shows "MyDocument" as the ct of te document, as expected.

So, what' going on? My JSOM is supposed to process only the documents of ct MyDocument, but it gets fooled by this random ct coming from nowhere.

============================

This is he function I wrote after it was determined in the wanswers that this is the expected behaviour :

function IsContentType(ctId, expectedCtId)
{
    if (!ctId || !expectedCtId) {
        throw "bad arguments";
    }
    ctId = ctId.toString(); //the id you get from the item's fields is an object
    if (ctId == expectedCtId) return true;
    if (ctId.length == 74 && ctId.indexOf(expectedCtId) == 0) return true;
    return false;

}
Was it helpful?

Solution

That's just how SharePoint works.

Whenever you add a Content Type to a list/library what SharePoint adds is a Content Type inheriting for the Site Content Type, it does that in order to enable users to be able to change the Content Type at list level.

You should change your JSOM to work with document with content types inheriting from MyDocument

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top