Export (0) Print
Expand All

Views.UpdateView Method

Windows SharePoint Services 3
Modifies the specified view of the specified list.

Web Service: ViewsWeb Reference: http://<Site>/_vti_bin/Views.asmx

[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/UpdateView", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
public XmlNode UpdateView (
	string listName,
	string viewName,
	XmlNode viewProperties,
	XmlNode query,
	XmlNode viewFields,
	XmlNode aggregations,
	XmlNode formats,
	XmlNode rowLimit
)

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 Introduction to Collaborative Application Markup Language (CAML) fragment in the following form that contains the updated view schema and 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" xmlns=""> 
    <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>

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 (Microsoft Visual Basic) directive be included for the System.Xml namespace.

Web_Reference_Folder_Name.Views viewService = new Web_Reference_Folder_Name.Views();
viewService.Credentials= System.Net.CredentialCache.DefaultCredentials;

string strQuery = "<Where><And><Gt><FieldRef Name=\"Date_Field\" />" +
    "<Value Type=\"DateTime\">2003-6-10T12:00:00Z</Value></Gt>" +
    "<Gt><FieldRef Name=\"Number_Field\" />" +
    "<Value Type=\"Number\">200</Value></Gt></And></Where>" +
    "<OrderBy><FieldRef Name=\"Title\" /></OrderBy>";

string strRowLimit = "50";

string strViewFields = "<FieldRef Name=\"Title\" />" +
   "<FieldRef Name=\"Date_Field\" />" + 
   "<FieldRef Name=\"Number_Field\" />";

XmlDocument xmlDoc = new System.Xml.XmlDocument();

XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element,"Query","");
XmlNode ndRowLimit = xmlDoc.CreateNode(XmlNodeType.Element,"RowLimit","");
XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element,"ViewFields","");

ndQuery.InnerXml = strQuery;
ndRowLimit.InnerXml = strRowLimit;
ndViewFields.InnerXml = strViewFields;

XmlNode retNode = viewService.UpdateView("List_Name",
    "9781bd25-1f68-481f-81d3-1e4f3f9216dd", null, ndQuery, ndViewFields, 
    null, null, ndRowLimit);

Community Additions

ADD
Show:
© 2014 Microsoft