gpt4 book ai didi

javascript - CRM 2011 - 通过 javascript 更改状态代码 + 状态代码

转载 作者:行者123 更新时间:2023-11-29 15:49:07 25 4
gpt4 key购买 nike

我想在 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();
}
}

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

谢谢

最佳答案

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

尝试以下链接中的代码:

Set Status or State of a Record Using Jscript

关于javascript - CRM 2011 - 通过 javascript 更改状态代码 + 状态代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7850879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com