javascript - Retrieving Multiple Records OData java Scripts Microsoft Dynamics CRM -


i using following java script code retrieve contacts account id. set setting alert message debugging. not enter in success call message function.

ending following error

error while retrieval "error" : { "lang":"en-us", "value":"syntax error'\ufffd' @ position 20." }

i using following code.

function retrievemultiple(odatasetname, select, filter, successcallback) {     var serverurl = xrm.page.context.getserverurl();     var odata_endpoint = "/xrmservices/2011/organizationdata.svc";     var odatauri = serverurl + odata_endpoint + "/" + odatasetname + "?";      alert("retrievemultiple"+odatauri);      if (select) {         odatauri += "$select=" + select + "&";         alert("select error="+odatauri);     }      if (filter) {        odatauri += "$filter=" + filter;        alert("filter error="+odatauri);     }      $.ajax({        type: "get",        contenttype: "application/json; charset=utf-8",        datatype: "json",        url: odatauri,        beforesend: function (xmlhttprequest) {            //specifying header ensures results returned json.            var x = xmlhttprequest.setrequestheader("accept", "application/json");            alert(" in ajax :beforesend:" + x );        },        success: function (data, textstatus, xmlhttprequest) {            alert("in success function outside success");             if (successcallback) {                alert("successcallback in if");                 if (data && data.d && data.d.results) {                    alert("data && data.d && data.d.results"+data + data.d + data.d.results);                    successcallback(data.d.results, textstatus, xmlhttprequest);                    alert("data.d.results, textstatus, xmlhttprequest" + data.d.results + textstatus +       xmlhttprequest);                 }                 else if (data && data.d) {                      successcallback(data.d, textstatus, xmlhttprequest);                 }            else {                successcallback(data, textstatus, xmlhttprequest);            }        }     },     error: function (xmlhttprequest, textstatus, errorthrown) {         alert(" in erro function");          if (xmlhttprequest && xmlhttprequest.responsetext) {            alert(" in error function if");            alert("error while retrieval ; error – " + xmlhttprequest.responsetext);         }     } }); }  function readrecordsonsuccess(data, textstatus, xmlhttprequest) {     // loop through retrieved records     (var indx = 0; indx < data.length; indx++) {          alert("name – " + data[indx].name);     } }  function retrievecontactsbyaccountid() {     // pass ‘contact’ set name since reading contacts     var odatasetname = "contactset";      // column names of ‘contact’ (pass * read columns)     var columns = "firstname";      // read account guid     var accountid = xrm.page.data.entity.getid()      // prepare filter     var filter = "accountid/id eq guid’" + accountid + "‘";      alert("retrievecontactsbyaccountid"+filter);      retrievemultiple(odatasetname, columns, filter, readrecordsonsuccess); } 

looks common mistype ;) notice following string passing:

var filter = "accountid/id eq guid’" + accountid + "‘"; 

your apostrophes different usual ones

you need use regular '

var filter = "accountid/id eq guid'" + accountid + "'"; 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -