Lists.UpdateListItems 方法 (websvcLists)

Windows SharePoint Services 3
Adds, deletes, or updates the specified items in a list on the current site.
命名空间: websvcLists
程序集: STSSOAP (在 stssoap.dll 中)

语法


C#
VB

复制
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/UpdateListItems", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
public XmlNode UpdateListItems (string listName,XmlNode updates
)

参数

listName

A string that contains the name of the list. It is recommended that you use the list GUID surrounded by curly braces (i.e., "{GUID}"), but you can also use the list display name.

updates

A Batch element that contains one or more methods for adding, modifying, or deleting items and that can be assigned to a System.Xml.XmlNode object.

The following example shows how to modify column values for two specified items.

XML
复制
<Batch OnError="Continue" ListVersion="1"
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2"><Method ID="1" Cmd="Update"><Field Name="ID">4<Field><Field Name="Field_Name">Value</Field></Method><Method ID="2" Cmd="Update"><Field Name="ID" >6</Field><Field Name="Field_Name">Value</Field></Method>
</Batch>

An empty ViewName attribute in the Batch element causes the default view to be used. The ID attribute in each Method element uniquely identifies the specific update so that errors and return values can be properly identified. Each method that is posted contains Field elements that specify the ID of the item and the new field value for the item. The field ID does not correspond to the index of the item in the collection of items for the list.

The following example shows the format for adding a new item that contains both a Date value and a DateTime value.

XML
复制
<Batch OnError="Continue" ListVersion="1"
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2"><Method ID="1" Cmd="New"><Field Name='ID'>New</Field><Field Name="Title">Value</Field><Field Name="Date_Column">2007-3-25</Field><Field Name="Date_Time_Column">2006-1-11T09:15:30Z</Field></Method>
</Batch>

The following example shows how to delete two items.

XML
复制
<Batch OnError="Continue" ListVersion="1"
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2"><Method ID="1" Cmd="Delete"><Field Name='ID'>2</Field></Method><Method ID="2" Cmd="Delete"><Field Name='ID'>8</Field></Method>
</Batch>

注意:

IDs for deleted items are maintained after delete operations. Consequently, the example deletes the second and eighth items in the list, but 2 and 8 are not reassigned as the IDs of other items.

For descriptions of the various formats used for field types that can be passed in this parameter see SPListItem.

The following examples show the methods that can be posted for operations related to document libraries:

  • Create a folder

    XML
    复制
    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}"><Method ID="1" Cmd="New"><Field Name="ID">New</Field><Field Name="FSObjType">1</Field><Field Name="BaseName">Name</Field></Method>
    </Batch>
    

  • Update a folder

    XML
    复制
    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}"><Method ID="1" Cmd="Update"><Field Name="ID">3</Field><Field Name="owshiddenversion">1</Field><Field Name="FileRef">http://Server/[sites/][Site/]Shared Documents/Folder</Field><Field Name="FSObjType">1</Field><Field Name="BaseName">Name</Field></Method>
    </Batch>
    

  • Delete a folder

    XML
    复制
    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}"><Method ID="1" Cmd="Delete"><Field Name="ID">4</Field><Field Name="FileRef">http://Server/[sites/][Site/]Shared Documents/Folder</Field></Method>
    </Batch>
    

  • Update documents

    XML
    复制
    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}"><Method ID="1" Cmd="Update"><Field Name="ID">2</Field><Field Name="owshiddenversion">1</Field><Field Name="FileRef">http://Server/[sites/][Site/]Shared Documents/File</Field><Field Name="BaseName">Name</Field></Method>
    </Batch>
    

  • Delete documents

    XML
    复制
    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}"><Method ID="1" Cmd="Delete"><Field Name="ID">3</Field><Field Name="FileRef">http://Server/[sites/][Site/]Shared Documents/File</Field></Method>
    </Batch>
    

返回值

An XMLDATA fragment in the following form that shows the status of each method block posted through the updates parameter and that can be assigned to a System.Xml.XmlNode object. For items successfully updated, a row fragment is returned with the updated row values.

XML
复制
<Results xmlns="http://schemas.microsoft.com/sharepoint/soap/"><Result ID="1,Update"><ErrorCode>0x00000000</ErrorCode><z:row ows_ID="4" ows_Title="Title" ows_Modified="2003-06-19 20:31:21" ows_Created="2003-06-18 10:15:58" ows_Author="3;#User1_Display_Name" ows_Editor="7;#User2_Display_Name" ows_owshiddenversion="3" ows_Attachments="-1" ows__ModerationStatus="0" ows_LinkTitleNoMenu="Title" ows_LinkTitle="Title" ows_SelectTitle="4" ows_Order="400.000000000000" ows_GUID="{4962F024-BBA5-4A0B-9EC1-641B731ABFED}" ows_DateColumn="2003-09-04 00:00:00" ows_NumberColumn="791.00000000000000" xmlns:z="#RowsetSchema" /></Result><Result ID="2,Update"><ErrorCode>0x00000000</ErrorCode><z:row ows_ID="6" ows_Title="Title" ows_Modified="2003-06-19 20:31:22" ows_Created="2003-06-18 19:07:14" ows_Author="2;#User1_Display_Name" ows_Editor="6;#User2_Display_Name" ows_owshiddenversion="4" ows_Attachments="0" ows__ModerationStatus="0" ows_LinkTitleNoMenu="Title" ows_LinkTitle="Title" ows_SelectTitle="6" ows_Order="600.000000000000" ows_GUID="{2E8D2505-98FD-4E3E-BFDA-0C3DEBE483F7}" ows_DateColumn="2003-06-23 00:00:00" ows_NumberColumn="9001.00000000000000" xmlns:z="#RowsetSchema" /></Result>...
</Results>

In this example, the ows_Author and ows_Editor attributes pertain to lookup fields to another list in the database, representing the integer IDs of items in the UserInfo table and the actual values contained by these items within the table.

示例


The following code example modifies the values of two different field values within two items in a list on the current site. The example uses an XmlDocument object to create XmlNode objects for parameters.

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

C#
VB

复制
Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists();
listService.Credentials= System.Net.CredentialCache.DefaultCredentials;string strBatch = "<Method ID='1' Cmd='Update'>" + "<Field Name='ID'>4</Field>" +"<Field Name='Field_Number'>999</Field></Method>" +"<Method ID='2' Cmd='Update'><Field Name='ID' >6</Field>" +"<Field Name='Field_DateTime'>2003-11-11T09:15:30Z</Field></Method>"; XmlDocument xmlDoc = new System.Xml.XmlDocument();System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");elBatch.SetAttribute("OnError","Continue");
elBatch.SetAttribute("ListVersion","1");
elBatch.SetAttribute("ViewName","0d7fcacd-1d7c-45bc-bcfc-6d7f7d2eeb40");elBatch.InnerXml = strBatch;XmlNode ndReturn = listService.UpdateListItems("List_Name", elBatch);MessageBox.Show(ndReturn.OuterXml);

另请参阅


&amp;amp;lt;div&amp;amp;gt;&amp;amp;lt;img alt="DCSIMG" id="Img1" width="1" height="1" src="http://m.webtrends.com/dcsmgru7m99k7mqmgrhudo0k8_8c6m/njs.gif?dcsuri=/nojavascript&amp;amp;amp;amp;WT.js=No" /&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;a href="http://www.omniture.com" title="Web Analytics"&amp;amp;gt; &amp;amp;lt;img src="//msstonojsmsdn.112.2o7.net/b/ss/msstonojsmsdn/1/H.20.2--NS/0" height="1" width="1" border="0" alt="" /&amp;amp;gt; &amp;amp;lt;/a&amp;amp;gt;

转载于:https://www.cnblogs.com/nanfei/p/4039621.html

Sharepoint CAML 增删改查 List相关推荐

  1. java map 输入 查询 修改_Mybatis增删改查mapper文件写法详解

    1. 插入 INSERT sql命令(命令里通过#{}获取对象属性) EG: INSERT INTO PRAC_PERSON(p_NAME,P_PASSWORD) VALUES(#{name},#{p ...

  2. resultset mysql_MySQL数据库学习笔记(九)----JDBC的ResultSet接口(查询操作)、PreparedStatement接口重构增删改查(含SQL注入的解释)...

    [声明] 欢迎转载,但请保留文章原始出处→_→ [正文] 一.ResultSet接口的介绍: 对数据库的查询操作,一般需要返回查询结果,在程序中,JDBC为我们提供了ResultSet接口来专门处理查 ...

  3. 带头节点单链表的增删改查

    单链表有很多结构循环单链表,有头节点的单链表,无头节点的单链表,双节点单链表,以下源码是以有一个头节点的单链表为例写的增删改查的各种功能,就是下图 然后各个注释也在函数后面写着,这玩意确实还挺难,源码 ...

  4. vs连接mysql建一个表并增删查改_VS连接SQL Server数据库,增删改查详细教程(C#代码)...

    工具: 1.Visual Studio (我使用的是vs2013) 2.SQL Server  (我使用的是sql server2008) 操作: 1.打开SQL Server,打开后会看到数据库的初 ...

  5. MySQL数据库(五)使用pymysql对数据库进行增删改查

    折腾好半天的数据库连接,由于之前未安装 pip ,而且自己用的python 版本为3.6. 只能用 pymysql 来连接数据库,(如果有和我一样未安装 pip 的朋友请 点这里http://blog ...

  6. 易买网的一些增删改查

    正如题目所说的一样,今天就来说说易买网中的一些增删改查,主要的功能有注册.用户管理以及商品分类等! 1.注册 1.1 注册涉及到了一个ajax远端技术,主要是用来控制注册用户在数据库中是否存在: &l ...

  7. Mybatis入门:2(xml形式的增删改查)

    xml形式的增删改查 这里感觉没啥好讲的,照着代码自己敲一遍.认真再看看应该都懂的. Maven工程坐标 <?xml version="1.0" encoding=" ...

  8. 数据结构----单链表增删改查

    单链表的增删改查 一.链表(Linked List) 链表是有序列表,以节点的方式来存储的,链式存储: 每个节点包含data域,next域:指向下一节点: 链表的各个节点不一定是连续存储: 链表分为带 ...

  9. 02-CoreData 的增删改查

    CoreData 的增删改查 基本的增删改查的操作 1 数据库的创建 - (void)createDB {// 1.1 创建路径NSURL *modelURL = [[NSBundle mainBun ...

最新文章

  1. Install pysnmp for django
  2. 推荐10个很棒的 CSS3 开发工具
  3. Ubuntu 16.04安装Memcached(单机)
  4. Angular 开发中的 Source Map
  5. mysql 临时表 heap_mysql优化: 内存表和临时表
  6. 联想 android 5.1 root权限,联想a520一键root权限获取教程(图文)
  7. 【云计算】阿里云云计算架构师ACE成长路线v2
  8. foreach写失效的问题
  9. 《linux核心应用命令速查》连载七:bg:后台运行命令
  10. UVA11324 强连通+dp记忆化搜索
  11. 拓端tecdat|R语言模拟ARCH过程模型分析时间序列平稳性、波动性
  12. 转载 三极管饱和及深度饱和状态的理解和判断!!
  13. 计算机用户名显示TEMP,windows7登陆创建TEMP临时个人配置文件夹解决方法-系统操作与应用 -亦是美网络...
  14. Vue.js 开篇---Vue的介绍及准备工作
  15. 数据库 -- 基础操作(二)
  16. android 自定义剪裁,Android自定义View实现照片裁剪框与照片裁剪功能
  17. 如何设置Android手机的sqlite3命令环境
  18. 杰理之虚拟U盘升级【篇】
  19. java手机验证码登录代码_java web实现手机短信验证码登录实例
  20. matlab里颜色直方图的画法

热门文章

  1. 线程池拒绝策略-RejectedExecutionHandler
  2. vue中supermap iserver绘制使用的插件安装
  3. linux unzip到指定目录
  4. java中Map遍历的四种方法
  5. The Cow Lexicon
  6. 在docker for win中使用portainer管理容器
  7. 解读中国式O2O的未来发展三大趋势
  8. 在MySQL中创建cm-hive使用的数据库及账号
  9. CreateProcess 执行CMD命令,并重定向输出
  10. solutions for 'No Suitable Driver Found For Jdbc'