CRM JS返回fetchxml查询结果

var resultHelp = new RESTHelper();    

var result = resultHelp .Read(uid);    

if (result.results.length <= 0) { return; }     

var id=result.results[0].Id;   

   

  function RESTHelper() { }

        RESTHelper.prototype.Read = function (id) {

            var req = new XMLHttpRequest();            

           var baseurl = "/" + Xrm.Page.context.getOrgUniqueName();   

           queryurl = baseurl + "/xrmservices/2011/OrganizationData.svc/UserSet?$filter=Id/Id eq guid‘"+id+"‘";//此句话要修改(是你要查询的实体使用工具)

 

            req.open("GET", queryurl, false);

            req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

            req.setRequestHeader("Content-Length", 0);

            req.setRequestHeader("Accept", "application/json");

            req.send(null);

            // IE handles HTTP-204 incorrectly: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request

            if (req.readyState == 4 && (req.status == 200)) {

                return window.JSON.parse(req.responseText).d;

            }

            throw "REST error: " + req.status + ": " + req.responseText;

        }

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。