NEWFIELD

NEWFIELD

Adds a new field to a SharePoint Team Services list.

Syntax

<Method ID="IDText">
  <SetList Scope="Request">u_listname</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

  • ID = "IDText"

    Application-specific string. In Microsoft FrontPage, the string provides the sequence number of the method, the name of the method, and the name of the field to be added*.*

  • Scope = "Request"

    When set to Request, the Scope ***attribute sets the SharePoint Team Services variable for the rest of the request, unless the variable is changed by another tag. When the Scope=Request attribute is omitted, the variable remains set until the end tag. Note that when a user creates a list with name listname, internally SharePoint Team Services generates a unique name that may or may not be based upon the name or title of the list. *

  • 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 CAML Schema Reference.

  • 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 "ON," the new field is added to the default view; if it is "OFF," the field is not added to that view.

  • Name = "owshiddenversion"

    This is the current version number of the list. The NEWFIELD command will only work if SharePoint Team Services and the client program 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">u_CustomList1</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>

Return Value

Success

Returns the code attribute, which is a signed-decimal representation of an HRESULT.

Error

Returns an XML-encoded UTF8 text string. See SharePoint Team Services Error Message Format for more information.

Sample Output