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
Can I ask how do you read the request.send() for a particular element like division in my example from a javascript? Any link to the topic will be helpful , when I search for Jason request read I get all c# coding results!
You are right, I was in the Jlattimer REST building app and think it's the builder that froze, when I tried the URL it works like a charm.
Thank you Sreevalli!
Hi Rummy,
Could you share the error, I tried and it worked
my Request :
xxxxxxxxxxxxxxxxxxxx.api.crm4.dynamics.com/.../incidents(7E392284-0856-E911-A849-000D3AB0D976)$select=title,_customerid_value&$expand=customerid_contact($select=fullname,_parentcustomerid_value)
Given Response:
{"@odata.context":"xxxxxxxxxxxxxxxxxxxx.api.crm4.dynamics.com/.../v9.1/$metadata#incidents(title,_customerid_value,customerid_contact(fullname,_parentcustomerid_value))/$entity","@odata.etag":"W/\"6124687\"","title":"2132132312","_customerid_value":"bb7f72e1-543b-e911-a841-000d3ab1da01","incidentid":"7e392284-0856-e911-a849-000d3ab0d976","customerid_contact":{"@odata.etag":"W/\"4354842\"","fullname":"XXX XXXX","_parentcustomerid_value":"714c9cb7-9b3a-e911-a841-000d3ab1da01","contactid":"bb7f72e1-543b-e911-a841-000d3ab1da01"}}
Hi,
The "_fieldname_value" format works for the look up values in the same entity, when I try to do the same with the lookup value of the parent record it fails as before
$select=new_cardnameholder1,_new_fundraisingevent_value&$expand=new_FundRaiser($select=contactid,fullname,_lookup_divisionid_value)"
When I add _new_funraisingevent_value it works but freezes when I add _lookup_divisionid_value
Hi,
For the lookup fields we have to use the name in a format "_fieldname_value"
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156