Hello!
I'm trying to get some information from the contact entity to feed into a script on the Case entity.
I've built the below with the help of the CRM REST Builder, but I'm struggling to get any data pulled through into the variables.
Help, please!
function warningUserMessages() { var reportedByGuid = Xrm.Page.getAttribute("optevia_reportedbycontactid").getValue()[0].id; var cleanGuid = reportedByGuid.substr(1, reportedByGuid.length-2); //var dso_addresscheckstatus; //var dso_emailcheckstatus; //var dso_homephonecheckstatus; //var dso_mobilecheckstatus; //var dso_namecheckstatus; //var dso_workphonecheckstatus; var req = new XMLHttpRequest(); req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/contacts(" + cleanGuid + ")?$select=dso_addresscheckstatus,dso_emailcheckstatus,dso_homephonecheckstatus,dso_mobilecheckstatus,dso_namecheckstatus,dso_workphonecheckstatus", false); 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.onreadystatechange = function() { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 200) { var result = JSON.parse(this.response); var dso_addresscheckstatus = result["dso_addresscheckstatus"]; var dso_emailcheckstatus = result["dso_emailcheckstatus"]; var dso_homephonecheckstatus = result["dso_homephonecheckstatus"]; var dso_mobilecheckstatus = result["dso_mobilecheckstatus"]; var dso_namecheckstatus = result["dso_namecheckstatus"]; var dso_workphonecheckstatus = result["dso_workphonecheckstatus"]; } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send(); //Functional code here, which I think works fine (though I can't be very sure until the above works }