Quantcast
Viewing all articles
Browse latest Browse all 123975

Forum Post: RE: How to integrate CRM contact data to HTML page web resource?

xmlcallbackDoc = new ActiveXObject("Microsoft.XMLDOM");

xmlcallbackDoc.async = false;

xmlcallbackDoc.loadXML("<rows></rows>");

xmlDocLocal = new ActiveXObject("Microsoft.XMLDOM");

xmlDocLocal.async = false;

function RetrieveRecords() {

   debugger;

  var orgname = Xrm.Page.context.getOrgUniqueName();

  var serverurl = Xrm.Page.context.getServerUrl();

  var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";

  var query = serverurl + ODATA_ENDPOINT +"/new_contactSet?$filter=new_Country/Value eq 100000000";

  var jSonArray = getDatafromOrg(query);

  var xmlString = "";

  for (var count = 0; count < jSonArray[0].results.length; count++) {

      xmlString = "<row>"

      xmlString += "<cell>0</cell>";

      xmlString += "<cell>" + jSonArray[0].results[count].new_FistName + "</cell>";

      xmlString += "<cell>" + jSonArray[0].results[count].new_EmailID + "</cell>";

      xmlString += "<cell>" + jSonArray[0].results[count].new_City + "</cell>";

      xmlString += "<cell>" + jSonArray[0].results[count].new_State + "</cell>";

      xmlString += "<cell>" + jSonArray[0].results[count].new_Country + "</cell>";  

      xmlString += "</row>"

      xmlDocLocal.loadXML(xmlString);

      ChildNode = xmlDocLocal.getElementsByTagName("row")[0];

      ParentNode = xmlcallbackDoc.getElementsByTagName("rows")[0];

      ParentNode.appendChild(ChildNode);

  }

  bindgrid();

}

function bindgrid() {

   ListOfRecordsGgrid.parse(xmlrecordDoc.xml);

}

function getDatafromOrg(oDataUri) {

   var jSonArray = new Array();

   jQuery.ajax({

       type: "GET",

       contentType: "application/json; charset=utf-8",

       datatype: "json",

       url: oDataUri,

       async: false,

       beforeSend: function (XMLHttpRequest) {

           //Specifying this header ensures that the results will be returned as JSON.            

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

       },

       success: function (data, textStatus, XmlHttpRequest) {

           if (data && data.d != null) {

               jSonArray.push(data.d);

           }

       },

       error: function (XmlHttpRequest, textStatus, errorThrown) {

           // alert("Error :  has occured during retrieval of the data");

       }

   });

   return jSonArray;

}


Viewing all articles
Browse latest Browse all 123975

Trending Articles