crm使用soap批量删除数据

//批量删除数据

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);

}

时间: 2024-12-22 03:29:38

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

ajax批量删除数据

做网页经常要选择批量删除数据,基本都是异步请求批量删除,用到更多的是ajax批量删除.思路是前端ajax请求,传入ids(要删除对象id的字符串数组)到后台. 后台再遍历id,调用删除接口,删除数据.返回json给前台. 代码例子如下: 1 function deleteSaleChance() { 2 var selectedRows = $("#dg").datagrid("getSelections"); 3 if(selectedRows.length==0

bulk批量删除数据

bulk批量删除数据 1.  案列介绍 需要在一个1亿行的大表中,删除1千万行数据 需求是在对数据库其他应用影响最小的情况下,以最快的速度完成 如果业务无法停止的话,可以参考下列思路: 根据ROWID分片.再利用Rowid排序.批量处理.回表删除 在业务无法停止的时候,选择这种方式,的确是最好的 一般可以控制在每一万行以内提交一次,不会对回滚段造成太大压力 我在做大DML时,通常选择一两千行一提交 选择业务低峰时做,对应用也不至于有太大影响 2.  代码实现 测试环境 drop table t_

MVC4 批量删除数据

效果: JQuery代码: <script type="text/javascript">    $(document).ready(function () {        // 全选        $("#selectAll").click(function () {            $("input[name='RKEY']").prop("checked", this.checked);       

批量删除数据表

方法一:DeleteForm表名 方法二:TRUNCATETABLE在功能上与不带WHERE子句的DELETE语句相同:二者均删除表中的全部行.但TRUNCATETABLE比DELETE速度快,且使用的系统和事务日志资源少.DELETE语句每次删除一行,并在事务日志中为所删除的每行记录一项.TRUNCATETABLE通过释放存储表数据所用的数据页来删除数据,并且只在事务日志中记录页的释放.TRUNCATETABLE删除表中的所有行,但表结构及其列.约束.索引等保持不变.新行标识所用的计数值重置为

Hbase之批量删除数据

import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; impor

ssm框架下怎么批量删除数据?

ssm框架下批量删除怎么删除? 1.单击删除按钮选中选项后,跳转到js函数,由函数处理 2. 主要就是前端的操作 js 操作(如何全选?如何把选中的数据传到Controller中) 3.fun()函数(前端) /*添加删除选中栏*/ function fun(){ //给删除选中按钮添加单击事件 document.getElementById("delSelected").onclick = function(){ if(confirm("您确定要删除选中条目吗?"

asp+jquery实现批量删除数据

该方法优点是可以在同一页面既做查询又可删除,删除时用jquery改变form表单action的值 1.查询列表页: <script> //判断全选函数 function selectall(v){ var f=document.forms["form"] for (i=0;i<f.elements.length;i++) if(f.elements[i].name=="id") f.elements[i].checked=v; } //绑定删除时间

mysql动态执行sql批量删除数据

CREATE PROCEDURE `sp_delete_pushmsg_data`() BEGIN declare l_delete_date varchar(16); declare l_state_date varchar(16); declare l_dutyno int; declare l_row_cnt int DEFAULT 0; declare rn int default 0; declare i int default 0; set l_dutyno=101; set l_d

SQL 批量删除数据表

declare @name varchar(200) while(exists(select * from sysobjects where name like '表名前缀%')) begin select @name=name from sysobjects where name like '表名前缀%' exec ('drop table '+@name) end