【问题标题】:CRM 2011 - change statecode + statuscode by javascriptCRM 2011 - 通过 javascript 更改 statecode + statuscode
【发布时间】:2011-12-12 15:31:31
【问题描述】:

我想在 CRM 2011 中单击功能区按钮更改状态码和状态码。 我有调用 SOAP 的 javascript 函数:

if (typeof (Smpl) == "undefined") { Smpl = {}; }

Smpl.Items = {
change: function () {

    var entityId = Xrm.Page.data.entity.getId().substr(1, 36);
    var entityName = Xrm.Page.data.entity.getEntityName();
    var entityState = 0;
    var entityStatus = 100007891;

    var xml = "<?xml version='1.0' encoding='utf-8'?>" +
    "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
    "<soap:Body><Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'><Request xsi:type='SetStateDynamicEntityRequest'>" +
    "<Entity><Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>" + entityId + "</Id>" +
    "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>" + entityName + "</Name></Entity>" +
    "<State>" + entityState + "</State>" +
    "<Status>" + entityStatus + "</Status>" +
    "</Request></Execute></soap:Body></soap:Envelope>";

    var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
    xHReq.Open("POST", "http://my.full.com:80/web/mscrmservices/2007/CrmService.asmx", false);
    xHReq.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute");
    xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xHReq.setRequestHeader("Content-Length", xml.length);
    xHReq.send(xml);

    var resultXml = xHReq.responseXML;
    var errorCount = resultXml.selectNodes('//error').length;
    if (errorCount != 0) {
        var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
        alert(msg);
    }
    window.location.reload();
  }
}

我会说整个代码没问题,但当然,它根本不起作用:/ 在谷歌上,我只找到了一些 sn-ps,但与我的代码没有什么不同。 真的没有人通过 javascript 从功能区更改状态吗??

谢谢

【问题讨论】:

    标签: javascript soap dynamics-crm-2011


    【解决方案1】:

    要更改实体的状态,您需要在 .net 插件和 JScript 中使用 EntityMoniker。

    尝试以下链接中的代码:

    Set Status or State of a Record Using Jscript

    【讨论】:

      【解决方案2】:

      我在网上冲浪,因为我的一个朋友有同样的问题,我没有通过 JScript 更改 CRM 2011 中的 de statecode,但我想我有你的解决方案。

      如果是我的朋友,他的 statecode 值格式错误,他使用的是 0 或 1,服务返回一个错误告诉他,0 或 1 不是 statecode 的正确值,然后我在编码C# 你必须从枚举中输入一个值('Active' 或 'Inactive'),他将他的整数值更改为 'Active' 并且肥皂调用运行良好。

      如果您找到真正的解决方案,请报告 :)

      再见。

      【讨论】:

        猜你喜欢
        • 2012-01-05
        • 1970-01-01
        • 2014-01-11
        • 2012-02-02
        • 1970-01-01
        • 2012-12-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多