如何使旧的JS CRM 2011适应CRM 2015

扎拉

我是Microsoft Dynamics CRM的新手,正在使用CRM2015。正在使用CRM 2015,已获得修复为CRM 2011开发的错误脚本的帮助。它看起来像是旧语法,我没有我不知道如何使它适应JS for CRM2015。该脚本管理用户角色和角色名称,我已经通过fetchXML检索了数据。

function onChangeValutator()
{  
     var idUser = Xrm.Page.getAttribute("erm_valutatorid").getValue()[0].id;

     // Use the Xrm.Page.context.getAuthenticationHeader() method 
     // available from the CRM form to generate the Soap header text.
     var authenticationHeader = Xrm.Page.context.getAuthenticationHeader();

     // Define the SOAP XML to access Microsoft Dynamics CRM Web service.
     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\">" + 
     authenticationHeader+
     "<soap:Body>" + 
     // Specify the RetrieveMultiple message.
     "<RetrieveMultiple xmlns="+
     "\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
     // Specify that this is a QueryByAttribute query.
     "<query xmlns:q1="+
     "\"http://schemas.microsoft.com/crm/2006/Query\" "+
     "xsi:type=\"q1:QueryByAttribute\">" + 
     // Query the customeraddress entity.
     "<q1:EntityName>erm_source</q1:EntityName>" + 
     // Set the columns you want to return.
     "<q1:ColumnSet xsi:type=\"q1:ColumnSet\">" + 
     "<q1:Attributes>" + 
     "<q1:Attribute>erm_roleid</q1:Attribute>" + 
     "</q1:Attributes>" + 
     "</q1:ColumnSet>" + 
     // Specify the attribute that you are querying on.
     "<q1:Attributes>" + 
     "<q1:Attribute>erm_sourceid</q1:Attribute>" + 
     "</q1:Attributes>" + 
     // Set the value of the attribute using the customerid 
     // value of the case record.
     "<q1:Values>" + 
     "<q1:Value xsi:type=\"xsd:string\">"+
     idUser+
     "</q1:Value>" + 
     "</q1:Values>" + 
     "</query>" + 
     "</RetrieveMultiple>" + 
     "</soap:Body>" + 
     "</soap:Envelope>";

    var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
    xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xml);
    var doc = xmlHttpRequest.responseXML;
    var source = doc.selectSingleNode("//BusinessEntity");

    var guidSource = source.childNodes[0];

    if (guidSource.text != null)
    {
        // Define the SOAP XML to access Microsoft Dynamics CRM Web service.
         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\">" + 
         authenticationHeader+
         "<soap:Body>" + 
         // Specify the RetrieveMultiple message.
         "<RetrieveMultiple xmlns="+
         "\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
         // Specify that this is a QueryByAttribute query.
         "<query xmlns:q1="+
         "\"http://schemas.microsoft.com/crm/2006/Query\" "+
         "xsi:type=\"q1:QueryByAttribute\">" + 
         // Query the customeraddress entity.
         "<q1:EntityName>erm_companyrole</q1:EntityName>" + 
         // Set the columns you want to return.
         "<q1:ColumnSet xsi:type=\"q1:ColumnSet\">" + 
         "<q1:Attributes>" + 
         "<q1:Attribute>erm_name</q1:Attribute>" + 
         "</q1:Attributes>" + 
         "</q1:ColumnSet>" + 
         // Specify the attribute that you are querying on.
         "<q1:Attributes>" + 
         "<q1:Attribute>erm_companyroleid</q1:Attribute>" + 
         "</q1:Attributes>" + 
         // Set the value of the attribute using the customerid 
         // value of the case record.
         "<q1:Values>" + 
         "<q1:Value xsi:type=\"xsd:string\">"+
         guidSource.text+
         "</q1:Value>" + 
         "</q1:Values>" + 
         "</query>" + 
         "</RetrieveMultiple>" + 
         "</soap:Body>" + 
         "</soap:Envelope>";
         
        xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
        xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
        xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
        xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
        xmlHttpRequest.send(xml);
        doc = xmlHttpRequest.responseXML;
        var role = doc.selectSingleNode("//BusinessEntity");
        var roleName = role.childNodes[0];
        
        var lookupItem = new Array();
        lookupItem[0] = new Object();
        
        lookupItem[0].name = roleName.text;
        lookupItem[0].entityType = "erm_companyrole";
        lookupItem[0].id = guidRSource.text;
        
        Xrm.Page.getAttribute("erm_valutatorroleid").setValue(lookupItem);
        
    }		    
}

亨克·范·博伊恩(Henk van Boeijen)

您的查询使用的是Dynamics CRM 4.0 Web服务终结点,该终结点已弃用。除去从SOAP消息认证头和取代的端点地址"/mscrmservices/2007/CrmService.asmx"通过"xrmservices/2011/organization.svc/web"一个很好的例子可以在这里找到

随着Dynamics CRM 2016中Web API的引入,Microsoft完全取消了SOAP端点,但承诺在未来几年中将继续支持它。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在vs 2015上开发ms crm 2011插件

来自分类Dev

如何“取消发布” CRM 2011中的更改?

来自分类Dev

CRM 2015 ExecuteTransactionRquest与AssociateRequest示例?

来自分类Dev

CRM 2015如何以清晰的形式读取审核数据?

来自分类Dev

datetime插件crm 2011

来自分类Dev

CRM 2011 GUID ID

来自分类Dev

如何在CRM 2011开发中编写单元测试

来自分类Dev

如何加快Microsoft Dynamics CRM 2011中的查询

来自分类Dev

如何在LINQ中使用谓词来查询CRM 2011

来自分类Dev

如何使用CRM 2011实现MVC 4项目

来自分类Dev

如何获得实体的所有字段CRM 2011?

来自分类Dev

如何在Dynamics CRM 2011中获取每个帐户的活动?

来自分类Dev

如何在CRM 2011开发中编写单元测试

来自分类Dev

如何在CRM 2011中捕获QueueItem发布日期时间

来自分类Dev

如何获得所有实体领域的CRM 2011?

来自分类Dev

CRM2011:如何限制删除发票产品

来自分类Dev

如何使用JavaScript在CRM 2011中读取以下属性?

来自分类Dev

如何以编程方式关闭 crm 2011 中的案例

来自分类Dev

与CRM Explorer断开连接-Dynamics CRM 2011

来自分类Dev

Microsoft Dynamics CRM 2015 SDK设置

来自分类Dev

从CRM 2015表单导航到外部URL

来自分类Dev

在CRM Online 2015中配置选择列表

来自分类Dev

使用ExecuteTransactionRequest时出现FaultException(CRM 2015)

来自分类Dev

从Dynamic CRM 2011检索事件

来自分类Dev

CRM 2015,如何使用JavaScript显示/隐藏快速查看控件?

来自分类Dev

如何在Microsoft Dynamics CRM 2015中创建供应商?

来自分类Dev

如何通过SOAPui从Microsoft Dynamics CRM 2015获取数据或检索数据

来自分类Dev

如何将Comodo PositiveSSL证书添加到Microsoft Dynamics CRM 2015中

来自分类Dev

如何在Dynamics CRM 2015中进行列级加密?

Related 相关文章

热门标签

归档