I created js function to get record from different entity in my organization.
function retrieveRecord() {
var recordId = "62066436-52de-eb11-b802-00155d6e5e00";
//var clientURL = Xrm.Page.context.getClientUrl();
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() "/api/data/v8.2/lnkt_actiontakens(" recordId ")?$select=lnkt_name,lnkt_Device,lnkt_SubDevice,lnkt_Damage,lnkt_RootCause", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange = function () {
if (this.readyState == 4) {
req.onreadystatechange = null;
if (this.status == 200) {
var data = JSON.parse(this.response);
var action_name = data.lnkt_name;
var device = data.lnkt_device;
if(device != null)
{
var deviceId = device[0].id;
}
alert("Action name: " action_name " ,Device ID: " deviceId);
}
else {
var error = JSON.parse(this.response).error;
alert("Error retrieving Record – " error.message);
}
}
};
req.send();
}
I can get primary field which is "lnkt_name" (Single Line of Text). However i can't get the value of look up (lnkt_device). In the alert its return undefinied. How to get the lookup id, lookup entityname, and lookup label. Thanks