I am new to CRM and have been racking my brains and goggling until my fingers hurt. I just cannot see why my code returns nothing. Not even an error.
<HTML><HEAD><TITLE>Car Specialist</TITLE>
<SCRIPT type=text/javascript src="/_common/ClientGlobalContext.js.aspx"></SCRIPT>
<SCRIPT type=text/javascript src="/ISV/jQuery/js/jquery-1.7.1.min.js"></SCRIPT>
<SCRIPT language=javascript><script>
function retrieveCustomerInfo() {
return document.getElementById("esi_rmcarspecialistid").innerHTML = test;
var customerAttribute = parent.Xrm.Page.data.entity.attributes.get("esi_carspecialistid");
if (customerAttribute != null) {
customerValue = customerAttribute.getValue();
if (customerValue != null && customerValue[0] != null) {
var customerId = customerValue[0].id;
return retrieveRecord(customerId, "systemuser", retrieveCompleted, null);
}
}
function retrieveRecord(id, odataSetName, successCallback, errorCallback) {
var context = GetGlobalContext();
var serverUrl = context.getServerUrl();
var odataEndPoint = "/XRMServices/2011/OrganizationData.svc";
if (!id) {
alert("record id is required.");
return;
}
if (!odataSetName) {
alert("odataSetName is required.");
return;
}
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: serverUrl + odataEndPoint + "/" + odataSetName + "(guid'" + id + "')",
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function (data, textStatus, XmlHttpRequest) {
if (successCallback) {
successCallback(data.d, textStatus, XmlHttpRequest);
}
},
error: function (XmlHttpRequest, textStatus, errorThrown) {
if (errorCallback)
errorCallback(XmlHttpRequest, textStatus, errorThrown);
else
errorHandler(XmlHttpRequest, textStatus, errorThrown);
}
});
}
function retrieveCompleted(data, textStatus, XmlHttpRequest) {
/*Display the required fields and hide if the fields are null */
var entity = data;
var specialist = (entity.esi_rmcarspecialistid == null) ? "" : enitity.esi_rmcarspecialistid;
if (esi_rmcarspecialistid != "") {
document.getElementById("esi_rmcarspecialistid").innerHTML = 'Specialist: ' + Specialist;
}
else {
document.getElementById("esi_rmcarspecialistid").innerHTML = 'Specialist: ';
}
}
</SCRIPT>
<META charset=utf-8></HEAD>
<BODY onload=retrieveCustomerInfo() contentEditable=false>
<DIV id=esi_rmcarspecialistid></DIV></BODY></HTML>
Any help would be appreciated and will be rewarded with a marked as answer once I get a solution working.