Hi..
In addition to Ben, here is sample code to retrieve email address from your custom lookup field
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/contacts(1B8C0622-6E90-E811-80D8-005056B1622D)?$select=emailaddress1", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var result = JSON.parse(this.response);
var emailaddress1 = result["emailaddress1"];
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
You need changes in above code.. please check highlighted details
Instead of contacts use your custom lookup entity name, Guid you need to pass custom lookup id, emailaddress1 field should be email attribute from your custom entity.
Hope this will help..