admin管理员组文章数量:1423068
i can get the id of the contact but who i get the email of this contact ?????
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 );
}
}
i can get the id of the contact but who i get the email of this contact ?????
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 );
}
}
Share
Improve this question
edited Oct 27, 2015 at 13:29
ArK
21.1k67 gold badges111 silver badges136 bronze badges
asked Oct 27, 2015 at 13:20
user5493786user5493786
411 gold badge1 silver badge3 bronze badges
1
-
1
This is really really helpful! I was looking for that all day. The
lookupFieldObject.getValue()[0].name
will return the input value of the field upon validate and loss of focus! – scorpiophd Commented Oct 29, 2015 at 17:39
2 Answers
Reset to default 1You need to query the server for additional details of related records.
Have a look at Getting started with CRM 2011 JavaScript REST (OData) Web Service Calls and Retrieve Data using OData queries with Javascript in CRM 2013 to get you going in the right direction.
OData endpoint, once again, to the rescue:
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);
}
本文标签: get a value from lookup field in crm 2015 using javascriptStack Overflow
版权声明:本文标题:get a value from lookup field in crm 2015 using javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744751704a2623219.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论