Note that there are some explanatory texts on larger screens.

plurals
  1. POSharePoint: Content Type ID differs form content type id attached to a list instance
    primarykey
    data
    text
    <p>I got a question regarding content types and their IDs and how to use them with the object model. </p> <p>First of all, I defined some site columns, a content type using these columns and a list definition using this content type via CAML. Each of the three components is realized as a feature. Another feature creates a list instance of this list definition. </p> <p>So when I try to add a new item to the list using the my content type I use the following code. </p> <pre><code> SPListItem listItem = list.Items.Add(); SPContentType type = list.ContentTypes[new ContentTypeId("0x010044fb4458c2eb4800825910845a35554c")]; listItem["ContentTypeId"] = type.Id; listItem["Title"] = "Titel"; listItem.Update(); </code></pre> <p>When I execute this piece of code the type object is still null, also I'm sure the content type is attached to the list. Debugging the code and inspecting the list's content types shows me that the content type attached to the list doesn't have the id I defined in the content type definition (CAML). The id within the list instance is different but starts with the one I defined in the content type definition. <strong>0x010044FB4458C2EB4800825910845A35554C</strong>0077D683BDD9969F4E920A27C334463321</p> <p>So is this behavior normal? I expected the content type attached to the list to have the same id as in the definition. </p> <p>My main goal is avoiding to use the name of the content type to retrieve it from the list's content types, but to use the unique id.</p> <p>bye Flo</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload