1

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;

}

1 Answer 1

2

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

3
  • thanks. I will write some custom code, I'm just worried to screw things up, i.e. to return false positives (or to omit some documents) when trying to filter the documents of that Content Type. Would you have an idea on how to do that filtering directly in the Caml Query? May 29, 2018 at 13:02
  • <BeginsWith> <FieldRef Name='ContentTypeId'/> <Value Type='ContentTypeId'>0x0101005270FFF03AD51B41B40BB981DFDFEAA0</Value> </BeginsWith> May 29, 2018 at 13:07
  • Almost Perfect. This will not only return the documents of CT "GAPDocument", but also the custom CTs that I've created and that inherit from GAPDocument too. But it's outside of the scope of this question. Thank you all! May 29, 2018 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.