Hi,
I am trying to get the look up value from the parent record, based on the look up value I have to set the child record's fields.
The retrieve query works for text data from parent record, but gives bad request error when I try to get the parent record's look up field value.
In this example, it works fine if I just include $expand=new_FundRaiser($select=fullname)
but not when I add lookup_divisionid, any obvious error you can see?
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/new_fundraisings(46AA6C06-3652-E911-811A-005056919B9D)?$select=new_cardnameholder1&$expand=new_FundRaiser($select=fullname,lookup_divisionid)", 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 new_cardnameholder1 = result["new_cardnameholder1"];
if (result.hasOwnProperty("new_FundRaiser")) {
var new_FundRaiser_fullname = result["new_FundRaiser"]["fullname"];
var new_FundRaiser_upbeat_divisionid = result["new_FundRaiser"]["lookup_divisionid"];
}
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
*This post is locked for comments