function GetParentValue() {
//Fetch the case id.
//calling this function on Email form
var regardingObject = Xrm.Page.getAttribute("regardingobjectid");
if (regardingObject.getValue() != null) {
//OData URI to get address information from parent account record
var oDataURI = Xrm.Page.context.getClientUrl()
+ "/XRMServices/2011/OrganizationData.svc/"
+ "IncidentSet(guid'" + regardingObject.getValue()[0].id + "')"
+ "?$select=Title,ContactId";
//Asynchronous XMLHttpRequest to retrieve account record
var req = new XMLHttpRequest();
req.open("GET", encodeURI(oDataURI), true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
debugger;
if (this.readyState == 4 /* complete */) {
req.onreadystatechange = null; //avoids memory leaks
if (this.status == 200) {
//parse the response string as a JSON object into the successCallback method.
//successCallback(JSON.parse(this.responseText).d);
//Directly show the alert and assign accordingly to other values
alert(JSON.parse(JSON.parse(this.responseText).d.Title));
}
else {
errorCallback(CaseID);
}
}
};
req.send();
}
}
//Call the GetParentValue method on OnLoad.
//Fetch the case id.
//calling this function on Email form
var regardingObject = Xrm.Page.getAttribute("regardingobjectid");
if (regardingObject.getValue() != null) {
//OData URI to get address information from parent account record
var oDataURI = Xrm.Page.context.getClientUrl()
+ "/XRMServices/2011/OrganizationData.svc/"
+ "IncidentSet(guid'" + regardingObject.getValue()[0].id + "')"
+ "?$select=Title,ContactId";
//Asynchronous XMLHttpRequest to retrieve account record
var req = new XMLHttpRequest();
req.open("GET", encodeURI(oDataURI), true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
debugger;
if (this.readyState == 4 /* complete */) {
req.onreadystatechange = null; //avoids memory leaks
if (this.status == 200) {
//parse the response string as a JSON object into the successCallback method.
//successCallback(JSON.parse(this.responseText).d);
//Directly show the alert and assign accordingly to other values
alert(JSON.parse(JSON.parse(this.responseText).d.Title));
}
else {
errorCallback(CaseID);
}
}
};
req.send();
}
}
//Call the GetParentValue method on OnLoad.
No comments:
Post a Comment