I have my query built to pull contact information from the contact form and populate it on the Ticket form. Here is my query:
function getContactDetails()
{
var lookUpObjectValue = Xrm.Page.getAttribute("new_customer").getValue();
if ((lookUpObjectValue != null))
{
var lookuptextvalue = lookUpObjectValue[0].name;
var lookupid = lookUpObjectValue[0].id;
//alert(lookupid);
var serverUrl = Xrm.Page.context.getServerUrl();
//The XRM OData end-point
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
var odataSetName = "ContactSet";
var odataSelect = serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "(guid'" + lookupid + "')";
//alert(odataSelect);
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: odataSelect,
beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
success: function (data, textStatus, XmlHttpRequest) {
var result_contact= data.d;
//alert(result_contact.firstname);
var mc_phone1 = result_contact.telephone1;
//replace the fields with the fields on your entity
Xrm.Page.getAttribute("new_phone").setValue(mc_phone1);
Xrm.Page.getAttribute("new_email").setValue(result_contact.emailaddress1);
},
error: function (XmlHttpRequest, textStatus, errorThrown) { alert('OData Select Failed: ' + odataSelect); }
});
}
}
It runs with out error and gets to the OdataSelect part and you can hit the page and it has the information I need to pull but when it goes through the rest of the query starting at the $.ajax part it is not pulling the data I need and populating it on the form. Am I missing something that is preventing this from working?