none
Using JScript/Rest to GetData in CRM2011(using OrganizationData.svc) RRS feed

  • 问题

  • I've used Jscript code to get one entity some records in CRM2011.

    The table  Account is the main table,and the table1 Account1 is link table ,

    use the filed new_listid2 relation..I use the key field new_listid2 of Account ,want to get the table Account1 some records.

    but it will get some error ..

     

    here is code:

    function GetData()

    {

    var url = "/TestCRM/XRMServices/2011/OrganizationData.svc";
        var retrieveusersReq = new XMLHttpRequest();


        retrieveusersReq.open("GET", url + "/Account1Set?$select=new_listid1,new_name&$filter=new_listid2 eq '%09BCDE0F-0505-E111-B8B6-00155DD20E09%'", true);

        retrieveusersReq.setRequestHeader("Accept", "application/json");
        retrieveusersReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        retrieveusersReq.onreadystatechange = function () {
            loadUsersResponse(retrieveusersReq);
        };
        retrieveusersReq.send();

    }

    function loadUsersResponse(retrieveusersReq) {
        var tmpstr = "";
        if (retrieveusersReq.readyState == 4 /* complete */) {
            if (retrieveusersReq.status == 200) {
                //Success
                var retrievedUsers = JSON.parse(retrieveusersReq.responseText).d.results;
                for (var i = 0; i < retrievedUsers.length; i++) {
                    var user = retrievedUsers[i];
                    tmpstr += "user.listid1='" + user.listid1+ "',user.new_name='" + user.new_name+ "',";
                }
                alert(tmpstr);
            }
            else {
                  errorHandler(retrieveusersReq);
            }
        }
    }


    when i call function GetData,it's some error .

    i want to get some records like sql is :

    select listid1,new_name from Account1 where new_listid2 = '%09BCDE0F-0505-E111-B8B6-00155DD20E09%'

    i used ConditionOperator 'eq' or 'like' or'in' ,but could't get records .

    Any idea why I'm getting this error or ideas for an alternate approach.

    thanks.

    2011年11月9日 14:06

答案