Hi guys
I have an entity known as booking screen with some fields including booking number, first name, last name etc
I want to add a text field in another entity (medical) form where if I put the booking number, the name fields should auto populate in that form based on the booking number value and data from the first form.
Here is my code, but the issue is it is not populating anything on my medical form.
function getContactDetails()
{
var lookUpObjectValue = Xrm.Page.getAttribute("inmate_lookupbookingscreen").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 odataSelect = serverUrl + ODATA_ENDPOINT + "/" + "(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.AccountNumber);
//replace the fields with the fields on your entity
Xrm.Page.getAttribute("inmate_firstname").setValue(result_contact.inmate_firstname);
Xrm.Page.getAttribute("inmate_lastname").setValue(result_contact.inmate_lastname);
},
error: function (XmlHttpRequest, textStatus, errorThrown) { alert('OData Select Failed: ' + odataSelect); }
});
}
}