How can I retrieve the email of a contact when I already have their ID?
function getEmailFromContactID(){
var contactId, contactName, contactEmail, contactObject;
// mbmhr_employee is the lookup field name that we want to retrieve values from
contactObject = Xrm.Page.data.entity.attributes.get('mbmhr_employee');
if (contactObject.getValue() != null) {
contactId = contactObject.getValue()[0].id;
contactName = contactObject.getValue()[0].entityType;
contactEmail = contactObject.getValue()[0].email;
Xrm.Page.getAttribute("mbmhr_test22").setValue(contactEmail);
}
}