共用方式為


NEWFIELD Method

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Adds a field to a SharePoint list.

Note

This method is deprecated and may not be supported in future releases. Instead, use the following Web service method:UpdateList Web service method.

<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>

Parameters

Parameter

Description

ID = "Text"

Application-specific string. In an HTML editor compatible with Microsoft Windows SharePoint Services, such as Microsoft Office SharePoint Server 2007, the string provides the sequence number and name of the method.

Scope = "Request"

When set to Request, the Scope attribute sets the variable for the scope of the enclosing Method element, unless the variable is changed by another tag.

Name = "Cmd"

Must be set to NEWFIELD.

Name = "FieldXML"

The XML description of the new field. For the full set of available attributes and values that can be included, see the Field element definition in the reference for Collaborative Application Markup Language Core Schemas.

Name = "AddToDefaultView"

A view is a named set of rules describing how the items in a list are displayed. Each list has a default view associated with it. If AddToDefaultView is set to ON, the field is added to the default view; if it is set to OFF, the field is not added to that view.

Name = "owshiddenversion"

This is the current version number of the list. The NEWFIELD command only works if Windows SharePoint Services and the client application agree on the version number of the list. This ensures that only one user at a time can modify the list schema.

Decoded

<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>

See Also

Concepts

Error Message Format for Windows SharePoint Services