Hi,
I have a lookup field named "new_smstemplateid" related to the the entity "new_smstemplate", i need to retrieve another field 'new_messagetemplate" but the code below don't return any data :
function GetRelated() { var contact = new Array(); contact = Xrm.Page.getAttribute("new_smstemplateid").getValue(); if (contact == null) { return; } var serverUrl = Xrm.Page.context.getClientUrl(); var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/new_smstemplateSet?$select=new_messagetemplate&$filter=new_smstemplateid eq guid'" + contact[0].id + "'"; alert(oDataSelect); var retrieveReq = new XMLHttpRequest(); retrieveReq.open("GET", oDataSelect, false); retrieveReq.setRequestHeader("Accept", "application/json"); retrieveReq.setRequestHeader("Content-Type", "application/json;charset=utf-8"); retrieveReq.onreadystatechange = function () { GetContactData(this); }; retrieveReq.send(); } function GetContactData(retrieveReq) { if (retrieveReq.readyState == 4) { if (retrieveReq.status == 200) { var retrieved = JSON.parse(retrieveReq.responseText).d; Xrm.Page.getAttribute("new_message").setValue(retrieved.results[0].new_messagetemplate); } } }
thanks for your help