Compartilhar via


Lists.UpdateList method

Atualiza uma lista com base nas definições de campo especificado e propriedades da lista.

Namespace:  WebSvcLists
Assembly:  STSSOAP (in STSSOAP.dll)

Syntax

'Declaração
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/UpdateList", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/",  _
    ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function UpdateList ( _
    listName As String, _
    listProperties As XmlNode, _
    newFields As XmlNode, _
    updateFields As XmlNode, _
    deleteFields As XmlNode, _
    listVersion As String _
) As XmlNode
'Uso
Dim instance As Lists
Dim listName As String
Dim listProperties As XmlNode
Dim newFields As XmlNode
Dim updateFields As XmlNode
Dim deleteFields As XmlNode
Dim listVersion As String
Dim returnValue As XmlNode

returnValue = instance.UpdateList(listName, _
    listProperties, newFields, updateFields, _
    deleteFields, listVersion)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/UpdateList", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/", 
    ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public XmlNode UpdateList(
    string listName,
    XmlNode listProperties,
    XmlNode newFields,
    XmlNode updateFields,
    XmlNode deleteFields,
    string listVersion
)

Parâmetros

  • listName
    Type: System.String

    Uma string que contém o GUID da lista.

  • listProperties
    Type: System.Xml.XmlNode

    Um fragmento XML no seguinte formato que pode ser atribuído a um objeto de System.Xml.XmlNode e que contém todas as propriedades de lista a ser atualizado.

  • newFields
    Type: System.Xml.XmlNode

    Um fragmento XML no seguinte formato que pode ser atribuído a um objeto de System.Xml.XmlNode e que contém os elementos de campo dentro de blocos de método para que as operações de adicionar podem ser controladas individualmente.

  • updateFields
    Type: System.Xml.XmlNode

    Um fragmento XML no seguinte formato que pode ser atribuído a um objeto de System.Xml.XmlNode e que contém os elementos de campo dentro de blocos de método para que as operações de atualização podem ser controladas individualmente.

  • deleteFields
    Type: System.Xml.XmlNode

    Um fragmento XML no seguinte formato que contém os elementos de campo especificando os nomes dos campos para excluir dentro de blocos de método para que as operações de excluir possam ser controladas individualmente.

  • listVersion
    Type: System.String

    Uma string que contém a versão da lista que está sendo atualizada para que pode ser executada a detecção de conflito.

Valor retornado

Type: System.Xml.XmlNode
Um fragmento XML que contém o esquema de lista depois que as alterações são aplicadas e um bloco de resultados para cada campo que é novo e atualizado ou excluído. O fragmento é no seguinte formato e pode ser atribuído a um objeto System.Xml.XmlNode .

<Results xmlns="https://schemas.microsoft.com/sharepoint/soap/">
   <NewFields>
      <Method ID="1">
         <ErrorCode>0x00000000</ErrorCode>
         <Field Type="DateTime" DateOnly="TRUE" 
            DisplayName="Field1_Display_Name" FromBaseType="TRUE" 
            Name="Field1_Name" ColName="datetime2" />
      </Method>
      <Method ID="2">
         <ErrorCode>0x00000000</ErrorCode>
         <Field Type="Text" DisplayName="Field2_Display_Name" 
            Required="TRUE" FromBaseType="TRUE" 
            Description="Description" Name="Field2_Name" 
            ColName="nvarchar4" />
      </Method>
   </NewFields>
   <UpdateFields>
      <Method ID="3">
         <ErrorCode>0x00000000</ErrorCode>
         <Field Type="Number" Name="NumberColumn" DisplayName="Numbers" 
            Required="TRUE" FromBaseType="TRUE" 
            Description="Description" ColName="float1" />
      </Method>
      <Method ID="4">
         <ErrorCode>0x00000000</ErrorCode>
         <Field Type="Text" Name="Title" DisplayName="Title" 
            Required="TRUE" FromBaseType="TRUE" 
            Description="Description" ColName="nvarchar1" />
      </Method>
   </UpdateFields>
   <DeleteFields>
      <Method ID="5">
         <ErrorCode>0x00000000</ErrorCode>
      </Method>
      <Method ID="6">
         <ErrorCode>0x00000000</ErrorCode>
      </Method>
   </DeleteFields>
   <ListProperties DocTemplateUrl="" 
      DefaultViewUrl="/Site_Name/Lists/List_Name/AllItems.aspx" 
      ID="{6800A6B5-5B01-4E7B-B847-7F0C01F1F602}" Title="List_Name" 
      Description="New_Description" 
      ImageUrl="/_layouts/images/itgen.gif" 
      Name="{6800A6B5-5B01-4E7B-B847-7F0C01F1F602}" BaseType="0" 
      ServerTemplate="100" 
      Created="20030619 05:35:34" Modified="20030619 05:39:43" 
      LastDeleted="20030619 05:35:34" 
      Version="11" Direction="none" ThumbnailSize="" WebImageWidth="" 
      WebImageHeight="" 
      Flags="4096" ItemCount="0" AnonymousPermMask="" 
      RootFolder="/Site_Name/Lists/List_Name" 
      ReadSecurity="1" WriteSecurity="1" Author="1" 
      EventSinkAssembly="" EventSinkClass="" 
      EventSinkData="" EmailInsertsFolder="" AllowDeletion="True" 
      AllowMultiResponses="False" 
      EnableAttachments="True" EnableModeration="False" 
      EnableVersioning="False" Hidden="False" 
      MultipleDataList="False" Ordered="False" ShowUser="True" />
</Results>

Examples

O exemplo de código a seguir modifica os campos e as propriedades de uma lista especificada no site atual, mostrando como implementar cada parâmetro do método UpdateList . O exemplo usa o método GetList para retornar a versão da lista e usa um objeto XmlDocument para criar objetos de XmlNode para os parâmetros.

Este exemplo exige que um using (Visual c#) ou a ser incluído no espaço para nome System.Xml de diretiva de Imports (Visual Basic).

Dim listService As New Web_Reference_Folder.Lists()
listService.Credentials = System.Net.CredentialCache.DefaultCredentials

Dim ndList As XmlNode = listService.GetList("List_Name")
Dim ndVersion As XmlNode = ndList.Attributes("Version")

Dim xmlDoc = New System.Xml.XmlDocument()

Dim ndDeleteFields As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, 
   "Fields", "")
Dim ndProperties As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, 
   "List", "")
Dim ndTitleAttrib As XmlAttribute = 
   CType(xmlDoc.CreateNode(XmlNodeType.Attribute, "Title", ""), 
   XmlAttribute)
Dim ndDescriptionAttrib As XmlAttribute = 
   CType(xmlDoc.CreateNode(XmlNodeType.Attribute, "Description", ""), _
   XmlAttribute)
Dim ndNewFields As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, 
   "Fields", "")
Dim ndUpdateFields As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, 
   "Fields", "")

ndTitleAttrib.Value = "List_Name"
ndDescriptionAttrib.Value = "New_Description"

ndProperties.Attributes.Append(ndTitleAttrib)
ndProperties.Attributes.Append(ndDescriptionAttrib)

ndDeleteFields.InnerXml = "<Method ID='5'>
    <Field Name='Field1'/></Method>" + _
    "<Method ID='6'><Field Name='Field2'/></Method>"
ndNewFields.InnerXml = "<Method ID='1'>" + _ 
    "<Field Type='DateTime' DateOnly='TRUE' DisplayName='NewField1' 
        FromBaseType='TRUE'/>" + _
    "</Method><Method ID='2'>" + _
    "<Field Type='Text' DisplayName='NewField2' Required='TRUE' 
        FromBaseType='TRUE' Description='Description'/>" + _
    "</Method>"
ndUpdateFields.InnerXml = "<Method ID='3'>" + _
    "<Field Type='Number' Name='Field1' DisplayName='Field1_Display' 
        Required='TRUE' FromBaseType='TRUE' 
        Description='Description'/>" + "</Method><Method ID='4'>" + _
    "<Field Type='Text' Name='Field2' DisplayName='Field2_Display' 
        Required='TRUE' FromBaseType='TRUE' 
        Description='Description'/>" + _
    "</Method>"

Try

    Dim ndReturn As XmlNode = 
        listService.UpdateList("f2c47fbe-0fe1-4c84-8ed0-f56912f3dca7", 
        ndProperties, ndNewFields, _
        ndUpdateFields, ndDeleteFields, ndVersion.Value)

    MessageBox.Show(ndReturn.OuterXml)

    Catch ex As Exception

        MessageBox.Show("Message:" + ControlChars.Lf + ex.Message + 
            ControlChars.Lf + _
            "StackTrace:" + ControlChars.Lf + ex.StackTrace)

End Try
Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists();
listService.Credentials= System.Net.CredentialCache.DefaultCredentials;

XmlNode ndList = listService.GetList("List_Name");
XmlNode ndVersion = ndList.Attributes["Version"];

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

XmlNode ndDeleteFields = xmlDoc.CreateNode(XmlNodeType.Element, 
    "Fields", "");
XmlNode ndProperties = xmlDoc.CreateNode(XmlNodeType.Element, "List", 
    "");
XmlAttribute ndTitleAttrib = 
    (XmlAttribute)xmlDoc.CreateNode(XmlNodeType.Attribute, 
    "Title", "");
XmlAttribute ndDescriptionAttrib = 
    (XmlAttribute)xmlDoc.CreateNode(XmlNodeType.Attribute, 
    "Description", "");
XmlNode ndNewFields = xmlDoc.CreateNode(XmlNodeType.Element, 
    "Fields", "");
XmlNode ndUpdateFields = xmlDoc.CreateNode(XmlNodeType.Element, 
    "Fields", "");

ndTitleAttrib.Value = "List_Name";
ndDescriptionAttrib.Value = "New_Description";

ndProperties.Attributes.Append(ndTitleAttrib);
ndProperties.Attributes.Append(ndDescriptionAttrib);

ndDeleteFields.InnerXml="<Method ID='5'>" + 
   "<Field Name='Field1'/></Method>" + 
   "<Method ID='6'><Field Name='Field2'/>" + 
   "</Method>";

ndNewFields.InnerXml = "<Method ID='1'>" +
   "<Field Type='DateTime' DateOnly='TRUE' DisplayName='NewField1' 
        FromBaseType='TRUE'/>" + 
   "</Method><Method ID='2'>" +
   "<Field Type='Text' DisplayName='NewField2' Required='TRUE' 
      FromBaseType='TRUE' Description='Description'/>" +
   "</Method>";

ndUpdateFields.InnerXml = "<Method ID='3'>" +
   "<Field Type='Number' Name='Field1' DisplayName='Field1_Display' 
      Required='TRUE' FromBaseType='TRUE' 
      Description='Description'/>" +
   "</Method><Method ID='4'>" +
   "<Field Type='Text' Name='Field2' DisplayName='Field2_Display' 
      Required='TRUE' FromBaseType='TRUE' 
      Description='Description'/>" +
   "</Method>";

try
{
   XmlNode ndReturn = 
      listService.UpdateList("f2c47fbe-0fe1-4c84-8ed0-f56912f3dca7", 
      ndProperties, ndNewFields, ndUpdateFields, ndDeleteFields, 
      ndVersion.Value);

   MessageBox.Show(ndReturn.OuterXml);
}

catch (Exception ex)
{
   MessageBox.Show("Message:\n" + ex.Message + "\nStackTrace:\n" + 
      ex.StackTrace);
}

Ver também

Referência

Lists class

Lists members

WebSvcLists namespace