Hi Tom,
I've been playing around with the CRM Rest Builder and am a little stuck (novice here !!).
I'm trying to retrieve the job title of the contact within the leads entity (i.e. using parent contact id field).
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/leads(DCCE5294-9447-E711-8104-5065F38A4A21)?$expand=parentcontactid($select=jobtitle)", 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 leadid = result["leadid"];
if (result.hasOwnProperty("parentcontactid")) {
var parentcontactid_jobtitle = result["parentcontactid"]["jobtitle"];
}
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
It appears that the result will post a value when I save the record and not before...? I've tried changing true to false as well and it's making no difference.
Thanks in advance,