【问题标题】:How to create a Custom Content Type instance within a SharePoint List programmatically?如何以编程方式在 SharePoint 列表中创建自定义内容类型实例?
【发布时间】:2012-03-29 13:56:34
【问题描述】:

您可能知道,在 SharePoint 中,您可以创建一个列表内容类型(例如“Web 文件夹”),然后为此内容类型添加一些列(例如名称和路径)。

如何在 SharePoint 列表中创建自定义内容类型实例?

我的列表如下所示

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

我正在使用以下 xml 传递给 sharepoint Web 服务,我想在 WebFolder1 下创建一个新的“Web 文件夹”:

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

它在 WebFolder1 下创建了一个文件夹内容类型,而我需要创建一个“Web 文件夹”内容类型。

如何以编程方式创建自定义内容类型实例?

非常感谢,

【问题讨论】:

    标签: xml web-services sharepoint webpage


    【解决方案1】:

    简单地说,有一个名为“ContentType”的字段可以设置:

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

    因此不需要其他属性,我的 web 文件夹的名称变为“TestWebFolder11”并将位于“WebFolder1”下。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-22
      • 1970-01-01
      • 2011-04-16
      • 2015-12-27
      • 1970-01-01
      • 1970-01-01
      • 2011-12-28
      相关资源
      最近更新 更多