javascript - not able to get result length from ms crm web api call output in js -


below code snippet. trying fetch referenced entities manytoone relationship of annotation entity. in result, able object when i'm trying length of it, giving "undefined". please provide valuable suggestions on , how can assign referenced entity variable result.

or is there possibility retrieve entities associated annotation entity, using web api call ( dynamics 365).

function fetchit()  {      var req = new xmlhttprequest();      var webapicall = xrm.page.context.getclienturl() + "/api/data/v8.2/entitydefinitions(logicalname='annotation')?$select=logicalname&$expand=manytoonerelationships($select=referencedentity)";      req.open("get", webapicall, true);      req.setrequestheader("odata-maxversion", "4.0");      req.setrequestheader("odata-version", "4.0");      req.setrequestheader("accept", "application/json");      req.setrequestheader("content-type", "application/json; charset=utf-8");      req.setrequestheader("prefer", "odata.include-annotations=\"*\"");      req.onreadystatechange = function ()      {          if (this.readystate === 4)          {              req.onreadystatechange = null;              if (this.status === 200) {                                    var results = json.parse(this.response);                  alert("results.valuelength: " +results.value.length);                  (var = 0; < results.value.length; i++)                  {                      var referencedentity = results.value[i]["referencedentity"];                  }              } else {                  xrm.utility.alertdialog(this.statustext);              }          }      };      }

you have 2 problems

  1. you never send request. you're missing req.send()
  2. it won't results.value results.manytoonerelationships

then work


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -