function demo() {

    //操作记录的id

    var targetId = "a8a46444-ba10-e411-8a04-00155d002f02";

    //操作记录的实体名称

    var targetType = "new_config";

    //启用

    SetState(targetId, targetType, 1, 2);

    //停用

    SetState(targetId, targetType, 0, 1);

}

function SetState(targetId,targetType,state,status) {

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

     "<s:Body>" +

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

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

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

     "<a:KeyValuePairOfstringanyType>" +

     "<c:key>EntityMoniker</c:key>" +

     "<c:value i:type='a:EntityReference'>" +

     "<a:Id>" + targetId + "</a:Id>" +

     "<a:LogicalName>"+ targetType +"</a:LogicalName>" +

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

     "</c:value>" +

     "</a:KeyValuePairOfstringanyType>" +

     "<a:KeyValuePairOfstringanyType>" +

     "<c:key>State</c:key>" +

     "<c:value i:type='a:OptionSetValue'>" +

     "<a:Value>" + state + "</a:Value>" +

     "</c:value>" +

     "</a:KeyValuePairOfstringanyType>" +

     "<a:KeyValuePairOfstringanyType>" +

     "<c:key>Status</c:key>" +

     "<c:value i:type='a:OptionSetValue'>" +

     "<a:Value>"+ status +"</a:Value>" +

     "</c:value>" +

     "</a:KeyValuePairOfstringanyType>" +

     "</a:Parameters>" +

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

     "<a:RequestName>SetState</a:RequestName>" +

     "</request>" +

     "</Execute>" +

     "</s:Body>";

     "</s:Envelope>";

    

    getWebUrl(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. crm使用soap取消用户訪问记录权限

    //取消訪问权限 function demo() {     //操作记录的id     var targetId = "A8A46444-BA10-E411-8A04-00155D002F ...

  2. 我是如何将网站全站启用Https的?-记录博客安装配置SSL证书全过程

    评论»   文章目录 为什么要Https 如何选择Https 安装部署SSL证书 平滑过渡Https 搜索引擎的响应 启用Https小结 正如大家所看到的,部落全站已经启用了Https访问了,连续几天 ...

  3. MacBook 启用或停用 root 用户

    启用或停用 root 用户 选取苹果菜单 () >“系统偏好设置”,然后点按“用户与群组”(或“帐户”). 点按 ,然后输入管理员名称和密码. 点按“登录选项”. 点按“加入”(或“编辑”). ...

  4. crm使用soap分配记录

    //样例 function demo() {     //操作记录的id     var targetId = "A8A46444-BA10-E411-8A04-00155D002F02&q ...

  5. crm采用soap删除记录

    //抽样 function demo() {     //操作记录id     var targetId = "A8A46444-BA10-E411-8A04-00155D002F02&qu ...

  6. Oracle约束的启用和停用

      关于Oracle的约束概念和基本操作,我已经在以前的<Constraint基础概念>.<Constraint的简单操作>两篇文章中有过比较详细的介绍了,但是对于如何停用和启 ...

  7. Dynamics CRM 通过PowerShell启用AllowDeclarativeWorkflows即自定义XAML WorkFlows

    CRM的工作流即workflow,不了解的人乍听之下以为是审批流,其实不是的,CRM本身是不带审批功能的,要实现审批必须要第三方的工作流引擎的配合,当然你也可以自己开发. 工作流刚开始出现的时候只有异 ...

  8. linux ftp启用和停用及vsftpd安装 ssh 启用和停用命令及ssh的安装

    1.首页要用ftp:服务器上必须安装vsftpd 安装命令 yum installed vsftpd 查看vsftpd是否启动 root@DK:/home/daokr# service vsftpd ...

  9. crm使用soap更改下拉框的文本值

    //C#代码 //UpdateStateValueRequest updateStateValue = new UpdateStateValueRequest //{ //    AttributeL ...

随机推荐

  1. Java中常用的操作PDF的类库

    iText iText是一个能够快速产生PDF文件的java类库.iText的java类对于那些要产生包含文本,表格,图形的只读文档是很有用的.它的类库尤其与java Servlet有很好的给合.使用 ...

  2. 4th 循环结构概述和for语句的格式及其使用

    04.01_Java语言基础(循环结构概述和for语句的格式及其使用) A:循环结构的分类 for,while,do...while B:循环结构for语句的格式: for(初始化表达式;条件表达式; ...

  3. JQuery文档加载完成执行js的几种方法

    js中文档加载完毕.一般在body加一个onload事件或者window.onload = function () {} jQuery中有好多写法,平时也不注意,别人一问,还真觉得头大. 下面是我整理 ...

  4. HDU_1542_线段树【扫描线】

    Atlantis Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  5. C# 获取表中最大值

    ; if (db.LPicture.Any()) { // LPicture Newmode = db.LPicture.Where(n => ).FirstOrDefault(); start ...

  6. redis查看数据

    目前Redis缓存数据库在许多行业平台大量应用,有效解决了高并发等特定场景的应用性能瓶颈,Redis数据的查看.维护,性能监控有没有好用的工具呢,目前TreeSoft数据库管理系统可以满足实现需求. ...

  7. centos7 安装 PostgreSql

    确定你是管理员,然后运行命令: yum -y install postgresql-server postgresql-contrib 初始化数据库 postgresql-setup initdb 启 ...

  8. 一步一步教你用IntelliJ IDEA 搭建SSM框架(2)——配置mybatis-geneator

    我们要搭建整个SSM框架,所以要继续上篇文章没有完成的工作,下面配置mybatis-geneator,自动生成mybatis代码. 在上篇文章中的pom.xml的配置文件中已经加了mybatis-ge ...

  9. Java字符字符串类

    Java字符字符串类 Character 类 Character 类用于对单个字符进行操作.Character 类在对象中包装一个基本类型 char 的值在实际开发过程中,我们经常会遇到需要使用对象, ...

  10. fuel一键部署

    1. 所需物理主机的要求如下 内存:8GB+,推荐16GB: 磁盘:50GB+: 物理机OS:ubuntu-desktop-amd64 14.04(推荐) 或windows64位 物理机安装软件:安装 ...