Retrieve the phone number from the account entity to contact entity , when the company name is selected from the lookup, can any one rectify the error in the program below.
function getRecordDetails() {
var EntityName, EntityId, LookupFieldObject;
var Name = "";
var resultXml;
LookupFieldObject = Xrm.Page.data.entity.attributes.get('parentaccountid');
if (LookupFieldObject.getValue() != null) {
EntityId = LookupFieldObject.getValue()[0].id;
EntityName = LookupFieldObject.getValue()[0].entityType;
resultXml = getDetails(EntityName, EntityId);
// Retrieve text field value and set the value to current record field.
if (resultXml != null && resultXml.attributes['new_telephone1'] != null) {
var industrydetail = resultXml.attributes['new_telephone1'].value;
Xrm.Page.data.entity.attributes.get('new_mobilephone').setValue(industrydetail);
}
else
Xrm.Page.data.entity.attributes.get('new_mobilephone').setValue("");
}
}
function getDetails(EntityName, EntityId) {
var cols = ["new_telephone1","primarycontactid"];
var retrievedResult = XrmServiceToolkit.Soap.Retrieve(EntityName, EntityId, cols);
return retrievedResult;
}