Share via


UpdateView Method

The UpdateView method of the Views service modifies the specified view of the specified list.

Parameters

listName   A string that contains the internal name of the list.

viewName   A string that contains the GUID for the view.

viewProperties   An XML fragment that contains all the view-level properties as attributes, such as Editor, Hidden, ReadOnly, and Title.

query   A Query element containing the query that determines which records are returned and in what order, and that can be assigned to a System.Xml.XmlNode object. The following example performs a query for cases in which the ID field is less than 3, and displays items in the order of their titles:

<Query>
   <Where>
      <Lt>
         <FieldRef Name="ID" />
         <Value Type="Counter">3</Value>
      </Lt>
   </Where>
   <OrderBy>
      <FieldRef Name="Title" />
   </OrderBy>
</Query>

viewFields   A ViewFields element that specifies which fields to return in the query and that can be assigned to a System.Xml.XmlNode object, as in the following example:

<ViewFields><FieldRef Name="Title" /><FieldRef Name="ID" /></ViewFields>

aggregations   An Aggregations element that specifies the fields to aggregate and that can be assigned to a System.Xml.XmlNode object, as in the following example:

<Aggregations Value="On">
   <FieldRef Name="Title" Type="Count">
   <FieldRef Name="Number" Type="Sum">
</Aggregations>

formats   A Formats element that defines the grid formatting for columns and that can be assigned to a System.Xml.XmlNode object, as in the following example:

<Formats>
   <FormatDef Type="RowHeight" Value="67" />
   <Format Name="Attachments">
      <FormatDef Type="ColWidth" Value="75" />
   </Format>
   <Format Name="LinkTitle">
      <FormatDef Type="WrapText" Value="1" />
      <FormatDef Type="ColWidth" Value="236" />
   </Format>
   .
   .
   .
</Formats>

rowLimit   A RowLimit element that specifies the number of items, or rows, to display on a page before paging begins and that can be assigned to a System.Xml.XmlNode object. The fragment can include the Paged attribute to specify that the view return list items in pages. The following example sets a limit of 100 items per page:

<RowLimit Paged="True">100</RowLimit>

Return Value

A Collaborative Application Markup Language (CAML) fragment in the following form that contains the updated view schema and that can be assigned to a System.Xml.XmlNode object:

<UpdateViewResult>
   <View Name="{B5C3250A-1974-49E9-9F61-180F86704434}" DefaultView="TRUE" Type="HTML"
      DisplayName="All Contacts" Url="Lists/Contacts/AllItems.htm" BaseViewID="1" >
      <RowLimit Paged="TRUE">100</RowLimit>
      <ViewFields>
         <FieldRef Name="LinkTitle" />
         <FieldRef Name="FirstName" />
         <FieldRef Name="Company" />
         <FieldRef Name="WorkPhone" />
         <FieldRef Name="HomePhone" />
         <FieldRef Name="Email" />
      </ViewFields>
      <Query>
         <OrderBy>
            <FieldRef Name="Title" />
            <FieldRef Name="FirstName" />
         </OrderBy>
         <Where>
            <Lt>
               <FieldRef Name="DueDate"/>
               <Value Type="DateTime">Today + 1</Value>
            </Lt>
         </Where>
      </Query>
      <Aggregations>
         <FieldRef Name="Column1" Type="Minimum">
      </Aggregations>
      <RowLimit Paged="TRUE">100</RowLimit>
   </View>
</UpdateViewResult>

Example

The following code example modifies the query, row limit, and view fields in a view for a list, returning items whose values for a DateTime field and a Number field exceed specified values.

This example requires that a using (C#) or Imports (Visual Basic .NET) directive be included for the System.Xml namespace.

Requirements

Platforms: Microsoft Windows Server 2003

Web Reference: http://Server_Name/[sites/][Site_Name/]_vti_bin/Views.asmx