can we use "for" loop statement to retrieve details from JSON data ? RRS feed

  • Question

  • hi im using this code to retrieve annotation details using Odata and jquery.

    function annotation_details()
    var serverUrl =Xrm.Page.context.getServerUrl();
       var GUIDvalue = Xrm.Page.data.entity.getId();
     // Creating the Odata Endpoint
        var oDataPath = "http://server/orgname/XRMServices/2011/OrganizationData.svc";
        var retrieveReq = new XMLHttpRequest();
        var Odata = oDataPath + "/AnnotationSet?$select=DocumentBody,FileName,MimeType,ObjectId&$filter=ObjectId/Id eq guid'" + GUIDvalue + "'";
        retrieveReq.open("GET", Odata, false);
        retrieveReq.setRequestHeader("Accept", "application/json");
        retrieveReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        retrieveReq.onreadystatechange = function () { retrieveReqCallBack(this); };
    function retrieveReqCallBack(retrieveReq) {
        if (retrieveReq.readyState == 4 /* complete */) {
            var retrieved = this.parent.JSON.parse(retrieveReq.responseText).d;
           var message;
            var a = 0;
            for (var i in retrieved)
                 message = retrieved.results[a].FileName;

    as you can see the last 8 lines of the above code, im trying to show all filenames as alerts using "For" loop. but i can see the file name as alert which is in 0th place only. Looping is not working. 

    my requirement is to display all the file names as alerts. how to do this ? 

    Friday, July 20, 2012 11:53 AM


All replies