//批量删除数据

function demo() {

    //实体名称

    var entityname = "fw_student";

    var data = [];

    data.push("8B1D93C6-BF1E-E411-9406-00155D005802");

    data.push("20718494-0C2C-E411-9407-00155D005802");

executemultipleDelete(entityname, data);

}

function executemultipleDelete(name,iddata) {

    var request = "<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>";

    request += "<s:Body>";

    request += "<Execute xmlns='http://schemas.microsoft.com/xrm/2011/Contracts/Services' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>";

    request += "<request i:type='a:ExecuteMultipleRequest' xmlns:a='http://schemas.microsoft.com/xrm/2011/Contracts'>";

    request += "<a:Parameters xmlns:b='http://schemas.datacontract.org/2004/07/System.Collections.Generic'>";

    request += "<a:KeyValuePairOfstringanyType>";

    request += "<b:key>Requests</b:key>";

    request += "<b:value i:type='c:OrganizationRequestCollection' xmlns:c='http://schemas.microsoft.com/xrm/2012/Contracts'>";

    var len = iddata.length;

    for (var i = 0; i < len; i++) {

        addItem(name,iddata[i]);

    }

    request += "</b:value>";

    request += "</a:KeyValuePairOfstringanyType>";

    request += "<a:KeyValuePairOfstringanyType>";

    request += "<b:key>Settings</b:key>";

    request += "<b:value i:type='c:ExecuteMultipleSettings' xmlns:c='http://schemas.microsoft.com/xrm/2012/Contracts'>";

    request += "<c:ContinueOnError>false</c:ContinueOnError>";

    request += "<c:ReturnResponses>true</c:ReturnResponses>";

    request += "</b:value>";

    request += "</a:KeyValuePairOfstringanyType>";

    request += "</a:Parameters>";

    request += "<a:RequestId i:nil='true' />";

    request += "<a:RequestName>ExecuteMultiple</a:RequestName>";

    request += "</request>";

    request += "</Execute>";

    request += "</s:Body>";

    request += "</s:Envelope>";

execSoap(request);

}

function addItem(name,id) {

    var request = "<c:OrganizationRequest i:type='a:DeleteRequest'>";

    request += "<a:Parameters>";

    request += "<a:KeyValuePairOfstringanyType>";

    request += "<b:key>Target</b:key>";

    request += "<b:value i:type='a:EntityReference'>";

    request += "<a:Id>" + id + "</a:Id>";

    request += "<a:LogicalName>"+ name +"</a:LogicalName>";

    request += "<a:Name i:nil='true' />";

    request += "</b:value>";

    request += "</a:KeyValuePairOfstringanyType>";

    request += "</a:Parameters>";

    request += "<a:RequestId i:nil='true' />";

    request += "<a:RequestName>Delete</a:RequestName>";

    request += "</c:OrganizationRequest>";

return request;

}

//获取服务地址

function getWebUrl() {

    var serverUrl = Xrm.Page.context.getServerUrl();

    if (serverUrl.match(/\/$/)) {

        serverUrl = serverUrl.substring(0, serverUrl.length - 1);

    }

    return serverUrl + "/XRMServices/2011/Organization.svc/web";

}

//运行请求

function execSoap(request) {

    var ajaxRequest = new XMLHttpRequest();

    ajaxRequest.open("POST", getWebUrl(), true)

    ajaxRequest.setRequestHeader("Accept", "application/xml, text/xml, */*");

    ajaxRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

    ajaxRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");

    ajaxRequest.send(request);

}

crm使用soap批量删除数据的更多相关文章

  1. EntityFramework:支持同一事务提交的批量删除数据实现思路

    一切从一段代码说起... 下面一段代码是最近我在对一EF项目进行重构时发现的. protected override void DoRemove(T entity) { this.dbContext. ...

  2. ASP.NET MVC+EF框架+EasyUI实现权限管理系列(18)-过滤器的使用和批量删除数据(伪删除和直接删除)

    原文:ASP.NET MVC+EF框架+EasyUI实现权限管理系列(18)-过滤器的使用和批量删除数据(伪删除和直接删除) ASP.NET MVC+EF框架+EasyUI实现权限管系列 (开篇)   ...

  3. php 批量删除数据

    php 批量删除数据 :比如我们在看邮箱文件的时候,积攒了一段时间以后,看到有些文件没有用了 这时候我们就会想到把这些 没用的文件删除,这时候就用到了批量删除数据的功能,这里我是用了数据库原有的一个表 ...

  4. sqlalchemy批量删除数据、全量删除

    问题:sqlalchemy如何批量删除多条数据解决:使用参数synchronize_session=False,或for循环方法:        users = self.db.query(User) ...

  5. mysql 批量删除数据

    批量删除2000w数据 使用delete from table太慢 //DELIMITER DROP PROCEDURE if EXISTS deleteManyTable; create PROCE ...

  6. Hbase之批量删除数据

    import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; impo ...

  7. sql 2008批量删除数据表格

    DECLARE @Table NVARCHAR(300) DECLARE @Count Int = 0 DECLARE tmpCur CURSOR FOR SELECT name FROM sys.o ...

  8. PHP后台批量删除数据

    html <form action="" method="post"> <div><input type="submit ...

  9. PHP批量写入数据、批量删除数据

    批量插入可以参考$sql = "insert into data (id,ip,data)  values ";for($i=0;$i<100;$i++){$sqls[]=& ...

随机推荐

  1. Android利用Intent与其它应用交互

    前言: 上一篇博客给大家聊了Intent的定义.分类.属性和功能,相信大家对于Intent在Android中的作用已经清楚,这一篇博客将会给大家聊Intent的使用方法. Android系统的一个重要 ...

  2. js 获取现在时间一个月(N天)后的日期

    欢迎加入前端交流群交流知识&&获取视频资料:749539640 let today = new Date().getTime() let lastDay = getTimeByDay( ...

  3. TexturePacker贴图打包工具

    1.该软件是收费的,不过对于这么一款实用的工具来说,物有所值,下载地址 http://www.codeandweb.com/texturepacker 2.openGL载入纹理图片的时候,所用内存是会 ...

  4. redis启动加载过程、数据持久化

    背景 公司一年的部分业务数据放在redis服务器上,但数据量比较大,单纯的string类型数据一年就将近32G,而且是经过压缩后的. 所以我在想能否通过获取string数据的时间改为保存list数据类 ...

  5. 第7章 性能和可靠性模式 Server Clustering(服务器群集)

    上下文 您正在设计要部署应用程序的基础结构层.运行要求包括无法满足的可用性或性能能力,因为基础结构中存在性能瓶颈或故障单点. 影响因素 设计基础结构时,请考虑下列影响因素: 用户希望在使用应用程序时这 ...

  6. Windows下PHP的redis扩展下载地址

    Redis下载地址:http://windows.php.net/downloads/pecl/releases/redis/ igbinary下载地址:http://windows.php.net/ ...

  7. 用python 4行搞定基数排序

    from random import randint def main(): A = [randint(1, 99999999) for _ in xrange(9999)] for k in xra ...

  8. 软件开发的MVC构架

    MVC:IDE开发环境开发时,无意中使用的软件结构. 转自于wikipedia:http://zh.wikipedia.org/wiki/MVC 软件的层次划分:框架--组件(设计模式)--算法与数据 ...

  9. DP:***24种设计模式--转自刘伟

    转自于高人的文章:http://blog.csdn.net/lovelion/article/details/17517213 2012年-2013年,Sunny在CSDN技术博客中陆续发表了100多 ...

  10. Associated Values & enum

    it is sometimes useful to be able to store associated values of other types alongside these case val ...