我可以获得该联系人的ID,但是我收到此联系人的电子邮件?????
function getdata(){
var entityName, entityId, entityLabel, lookupFieldObject;
// parentaccountid is the lookup field name that we try to reach its values
lookupFieldObject = Xrm.Page.data.entity.attributes.get('mbmhr_employee');
if (lookupFieldObject.getValue() != null) {
entityId = lookupFieldObject.getValue()[0].id;
entityName = lookupFieldObject.getValue()[0].entityType;
entityLabel = lookupFieldObject.getValue()[0].name;
Xrm.Page.getAttribute("mbmhr_test22").setValue(entityLabel );
}
}
答案 0 :(得分:1)
您需要查询服务器以获取相关记录的其他详细信息。
请查看Getting started with CRM 2011 JavaScript REST (OData) Web Service Calls和Retrieve Data using OData queries with Javascript in CRM 2013,让您朝着正确的方向前进。
答案 1 :(得分:1)
OData终点,再一次,救援:
var contactId = null;
try { contactId = Xrm.Page.getAttribute('mbmhr_employee').getValue()[0].id; } catch(ex) { contactId = null; }
if(contactId !== null)
{
var req = new XMLHttpRequest();
var url = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/ContactSet(guid'" + contactId + "')?$select=EMailAddress1";
req.open("GET", url, true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
if(req.readyState == 4){
var data = JSON.parse(req.responseText);
// use data.d.EmailAddress1
}
};
req.send(null);
}