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. [ BZOJ 3445 ] Roadblock

    \(\\\) \(Description\) 给出一张\(N\) 个点\(M\)条边的无向图,选择一条边使其权值翻倍,求操作后比操作前最短路长度增量最大值. \(1\le N\le 250\),\(1 ...

  2. 精美对UI设计界面赏析

    最美的UI设计界面赏析 . 喜欢就关注我吧

  3. java攻城师之路--复习java web之servlet

    需要掌握的知识点:1.Servlet程序编写 ----- 生命周期2.ServletAPI Request Response 3.Cookie 和 Session Servlet 用来 动态web资源 ...

  4. 【译】x86程序员手册01

    Intel 80386 Reference Programmer's Manual 80386程序员参考手册 Chapter 1 -- Introduction to the 80386 第1章 - ...

  5. IF ERRORLEVEL 和 IF %ERRORLEVEL% 区别

      IF ERRORLEVEL 1 ( command )    与  IF %ERRORLEVEL%  LEQ 1 ( command  )  等效 也就是 ERRORLEVEL 1 等效于 &qu ...

  6. eclipse中代码整体左右移动的方法

    1.向左:将要移动的代码选中,然后按TAB键2.向右:将要移动的代码选中,然后按shift+tab键 kettas:  2009-8-21

  7. Android中Webview使用经验总结

    很早前就喜欢在Android中使用Webview组件结合JS来做应用,总结了一些不错的小经验,在这里持续更新,自己备忘,也希望给其他需要的同学一些参考- 1.添加权限 要用Webview,确认你在** ...

  8. CSS 之自定义滚动条样式

    ::-webkit-scrollbar {/*滚动条整体样式*/ width: 5px; /*高宽分别对应横竖滚动条的尺寸*/ height: 1px; } ::-webkit-scrollbar-t ...

  9. VMware Workstation Pro 15 for Windows下载与安装

    VMware Workstation Pro 15 for Windows下载与安装 一.下载 下载地址:https://my.vmware.com/cn/web/vmware/details?dow ...

  10. Error from server at http://127.0.0.1:8983/solr/xxx: undefined field type

    undefined field type就是说没有定义type类型,这样情况下,可以新建一个带type的索引,比如:{type:1, id:1, name:"张三"}