简体   繁体   中英

How to create a Custom Content Type instance within a SharePoint List programmatically?

As you may know, in SharePoint you can create a List Content Type (eg "Web folder") then add some columns for this content type (eg Name and Path).

How to create a custom Content Type instance within a SharePoint List?

My List is like below

ProductList
  WebFolder1
    Page1.aspx
    Page2.aspx
  WebFolder2
    Page3.aspx

I'm using the below xml to be passed to the sharepoint web service and i'd like to create a new "Web folder" under the WebFolder1:

<Method ID="1" Cmd="New">
<Field Name="FSObjType">1</Field>
<Field Name="Name">TestWebFolder11</Field>
<Field Name="BaseName">WebFolder1/TestWebFolder11</Field>
</Method>

And it creates a Folder content type under WebFolder1, whereas I'd need to create a "Web folder" content type instead.

How to create a custom content type instance programmatically?

Many thanks,

Simply, there is a fieldname called "ContentType" which can be set:

<Method ID="1" Cmd="New">
<Field Name="ContentType">Web folder</Field> // this is case-sensitive
<Field Name="BaseName">WebFolder1/TestWebFolder11</Field>
</Method>

so other properties are not required and the name of the my webfolder becomes "TestWebFolder11" and will be located under the "WebFolder1".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM