none
Powershell for Content Type Inheritance RRS feed

  • Question

  • Using SharePoint 2013, we have a set of custom content types that inherit from each other. For example, LLAbstractRE and LLAbstractNonRE inherit from LLAbstractBase which inherits from LLBase. Unfortunately, these content types were set up rather haphazardly so some site columns aren't really where they need to be or they are in multiple content types when really they should be in the LLBase content type and simply be inherited up.

    In the interest of efficiency and maintainability, we need to clean up our Content Types.  To do that, I'm trying to figure out where each of the Site Columns in each of the Content Types is inherited from.  In the Site Column list within the Content Type, I see a "Source" column.  But I can't find a property that corresponds to that column.  At first I thought it might be SourceId but as I looked further, I was wrong.

    I would really appreciate it if anyone can point me in the right direction.  Thanks.  Carol.

    Tuesday, April 14, 2015 6:23 PM

Answers

  • Hi Carol,

    Yes, the SPField.SourceId property can’t help you walk further if you want to sort out the inheritance of the site columns in the content types.

    In the current content type object, there is a property SPContentType.Id, which can return a SPContentTypeId object. In this SPContentTypeId object, there is a SPContentTypeId.Parent property which can return the parent content type object of the current content type.

    Since we can get the parent content type of the current content type, as well as the columns of a content type, as a workaround, I suggest you compare the columns of the current content types with the columns of the parent content type, it will lead you to find out the inheritance of a site column in different content types. Though it might not be a way as elegant as we want.

    Feel free to reply if there is any progress or finding, would be helpful to those who stuck with the similar issue.

    Thanks 

    Patrick Liang


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Marked as answer by cpnc Tuesday, April 21, 2015 1:22 PM
    Wednesday, April 15, 2015 8:08 AM
    Moderator

All replies

  • Hi Carol,

    Yes, the SPField.SourceId property can’t help you walk further if you want to sort out the inheritance of the site columns in the content types.

    In the current content type object, there is a property SPContentType.Id, which can return a SPContentTypeId object. In this SPContentTypeId object, there is a SPContentTypeId.Parent property which can return the parent content type object of the current content type.

    Since we can get the parent content type of the current content type, as well as the columns of a content type, as a workaround, I suggest you compare the columns of the current content types with the columns of the parent content type, it will lead you to find out the inheritance of a site column in different content types. Though it might not be a way as elegant as we want.

    Feel free to reply if there is any progress or finding, would be helpful to those who stuck with the similar issue.

    Thanks 

    Patrick Liang


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Marked as answer by cpnc Tuesday, April 21, 2015 1:22 PM
    Wednesday, April 15, 2015 8:08 AM
    Moderator
  • Thanks, Patrick.  I ended up doing this just by straight comparison (mostly because my Powershell expertise is limited).

    Carol

    Tuesday, April 21, 2015 1:22 PM