通过Javascript中的SOAP检索所有实体(CRM 2011)

通过Javascript中的SOAP检索所有实体(CRM 2011),soap,dynamics-crm-2011,dynamics-crm,dynamics-crm-online,Soap,Dynamics Crm 2011,Dynamics Crm,Dynamics Crm Online,通过下面的SOAP查询,我试图获取解决方案中的所有实体,但它不返回实体。也许第二只眼睛能帮上忙。你有没有看到我看不到的错误?谢谢大家! JCL.RetrieveAllEntitiesRequest = function (fnCallBack) { /// Returns a sorted array of entities var request = ""; request += "<s:Envelope xmlns:s=\"http://

通过下面的SOAP查询,我试图获取解决方案中的所有实体,但它不返回实体。也许第二只眼睛能帮上忙。你有没有看到我看不到的错误?谢谢大家!

JCL.RetrieveAllEntitiesRequest = function (fnCallBack) {
        /// Returns a sorted array of entities
        var request = "";
        request += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
        request += "  <s:Body>";
        request += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
        request += "      <request i:type=\"a:RetrieveAllEntitiesRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\">";
        request += "        <a:Parameters xmlns:b=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
        request += "          <a:KeyValuePairOfstringanyType>";
        request += "            <b:key>EntityFilters</b:key>";
        request += "            <b:value i:type=\"c:EntityFilters\" xmlns:c=\"http://schemas.microsoft.com/xrm/2011/Metadata\">Entity</b:value>";
        request += "          </a:KeyValuePairOfstringanyType>";
        request += "          <a:KeyValuePairOfstringanyType>";
        request += "            <b:key>RetrieveAsIfPublished</b:key>";
        request += "            <b:value i:type=\"c:boolean\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">true</b:value>";
        request += "          </a:KeyValuePairOfstringanyType>";
        request += "        </a:Parameters>";
        request += "        <a:RequestId i:nil=\"true\" />";
        request += "        <a:RequestName>RetrieveAllEntities</a:RequestName>";
        request += "      </request>";
        request += "    </Execute>";
        request += "  </s:Body>";
        request += "</s:Envelope>";

        return JCL._ExecuteRequest(request, "Execute", JCL._RetrieveAllEntitiesResponse, fnCallBack);
    };

JCL._ExecuteRequest = function (sXml, sMessage, fInternalCallback, fUserCallback) {
        'use strict';

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.open("POST", JCL.server + "/XRMServices/2011/Organization.svc/web", (fUserCallback !== null));
    xmlhttp.setRequestHeader("Accept", "application/xml, text/xml, */*");
    xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlhttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/" + sMessage);

    if (fUserCallback !== null) {
        // asynchronous: register callback function, then send the request.
        xmlhttp.onreadystatechange = function () {
            fInternalCallback.call(this, xmlhttp, fUserCallback);
        };

        xmlhttp.send(sXml);
    } else {
        // synchronous: send request, then call the callback function directly
        xmlhttp.send(sXml);
        return fInternalCallback.call(this, xmlhttp, null);
    }
};
JCL.retrieveAllentiesRequest=函数(fnCallBack){
///返回已排序的实体数组
var请求=”;
请求+=”;
请求+=”;
请求+=”;
请求+=”;
请求+=”;
请求+=”;
请求+=“EntityFilters”;
请求+=“实体”;
请求+=”;
请求+=”;
请求+=“RetrieveAsIfPublished”;
请求+=“真”;
请求+=”;
请求+=”;
请求+=”;
请求+=“检索资源”;
请求+=”;
请求+=”;
请求+=”;
请求+=”;
返回JCL.\u ExecuteRequest(请求,“执行”,JCL.\u RetrieveAllentiesResponse,fnCallBack);
};
JCL._ExecuteRequest=函数(sXml、sMessage、fInternalCallback、fUserCallback){
"严格使用",;
var xmlhttp=new XMLHttpRequest();
xmlhttp.open(“POST”,JCL.server+“/XRMServices/2011/Organization.svc/web”,(fUserCallback!==null));
setRequestHeader(“接受”,“应用程序/xml,text/xml,*/*”;
setRequestHeader(“内容类型”,“text/xml;charset=utf-8”);
setRequestHeader(“SOAPAction”http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/“+sMessage);
如果(fUserCallback!==null){
//异步:注册回调函数,然后发送请求。
xmlhttp.onreadystatechange=函数(){
调用(this,xmlhttp,fUserCallback);
};
send(sXml);
}否则{
//同步:发送请求,然后直接调用回调函数
send(sXml);
返回fInternalCallback.call(this,xmlhttp,null);
}
};
@Paul Way回复我后更新: 这是我在CRM Data Detective中选择需要调查的实体时收到的错误消息。我无法向该实体添加任何字段,这就是为什么我使用CRM Data Detective来确定可以删除哪个字段,但碰巧该解决方案也无法处理具有最大属性数的实体。你能看看保罗吗?非常感谢你


CRM 2011 SDK包含了一些很好的示例代码来实现这一点

嗯,我很尴尬:)

我已经更新了CRM Data Detective和JCL库,以支持CRM 2011 UR 12之前的版本


问题在于如何解析返回的XML。让我知道这是否解决了您的问题…

有任何错误/异常吗?没有,只是它返回0个实体:(您是否异步运行此方法?正如我看到的,您可以检查请求的就绪状态:
if(this.readyState==4/*complete*/){xmlhttp.onreadystatechange=null;if(this.status==200/*success*/){fInternalCallback.call(this,xmlhttp,fUserCallback);}else{JCL._Error(xmlhttp);}}}
@andriikulyk:谢谢你帮助我andriikulyk。我异步运行它。我已经添加了你的代码和“this.readyState”总是未定义的。非常重要的是
JCL.\u retrieveAllentiesResponse
看起来是什么样子,因为这就是所谓的。非常感谢您的回复。我们有两个环境,一个是UR 7,它不起作用,另一个是UR 15,它起作用,但它对所有实体都起作用,除了我遇到问题的实体事实上,我有一个无法添加新字段的实体,这就是为什么我尝试使用您的解决方案来找出哪些字段没有使用,我可以删除,但当我在CRM Data Detective中选择该实体时,它会显示一条错误消息。我用错误消息的屏幕截图更新了我的帖子,您能看一下吗?非常感谢非常感谢!尝试调整聚合查询限制:非常感谢Paul。由于CRM Data Detective仅在具有汇总15的Pre-Prod环境中为我工作,我可能无法更改preProd DB服务器上的限制。再次感谢您宝贵的帮助!