NEWFIELD 方法

上次修改时间: 2015年3月9日

适用范围: SharePoint Foundation 2010

向 SharePoint 列表中添加字段。

备注

此方法已被弃用,在以后的版本中可能不受支持。请改用以下 Web 服务方法:UpdateList(String, XmlNode, XmlNode, XmlNode, XmlNode, String) Web 服务方法。

<Method ID="Text">
  <SetList Scope="Request">GUID</SetList>
  <SetVar Name="Cmd">NEWFIELD</SetVar>
  <SetVar Name="FieldXML">&lt;Field Name=&quot;fieldname&quot;
    MaxLength=&quot;Integer&quot; DisplayName=&quot;displayname&quot;
    Description=&quot;text&quot; Type=&quot;Text&quot;/&gt;</SetVar>
  <SetVar Name="AddToDefaultView">[ON|OFF]</SetVar>
  <SetVar Name="owshiddenversion">Integer</SetVar>
</Method>

参数

参数

说明

ID = "Text"

特定于应用程序的字符串。在与 Microsoft Windows SharePoint Services 兼容的 HTML 编辑器(如 Microsoft Office SharePoint Server 2007)中,该字符串提供方法的序号和名称。

Scope = "Request"

当设置为 Request 时,Scope 属性将为封闭的 Method 元素的作用域设置变量,除非该变量已被另一个标记更改。

Name = "Cmd"

必须设置为 NEWFIELD。

Name = "FieldXML"

新字段的 XML 说明。有关可能包含的一整套可用属性和值,请参阅协作应用程序标记语言核心架构参考中的 Field 元素定义。

Name = "AddToDefaultView"

视图是指定的一组规则,这些规则用于描述项在列表中的显示方式。每个列表都具有与其关联的默认视图。如果 AddToDefaultView 设置为 ON,则会将字段添加到默认视图中;如果它设置为 OFF,则不会将字段添加到该视图中。

Name = "owshiddenversion"

它是列表的当前版本号。NEWFIELD 命令仅在 Windows SharePoint Services 和客户端应用程序均认可列表的版本号时才有效。这将确保每次只有一个用户可以修改列表架构。

已解码

<Method ID="0,NEWFIELDSample">
  <SetList Scope="Request">GUID</SetList>
  <SetVar Name="Cmd">NEWFIELD</SetVar>
  <SetVar Name="FieldXML">&lt;Field Name=&quot;Sample&quot;
    MaxLength=&quot;255&quot; DisplayName=&quot;Sample&quot;
    Description=&quot;sample description&quot; 
        Type=&quot;Text&quot;/&gt;</SetVar>
  <SetVar Name="AddToDefaultView">ON</SetVar>
  <SetVar Name="owshiddenversion">6</SetVar>
</Method>

请参阅

概念

SharePoint Foundation 的错误消息格式