Reputation: 151
I'm trying to form a query to retrieve related record properties in the new Dynamics CRM (2016) Web API. But I am unable to pass the GUID value dynamically unlike in CRM 2011-2015.
function getRelatedEntityStartAndEndDates(){
var parentOpportunity = Xrm.Page.getAttribute("rb_opportunityid").getValue()[0].id;
var clientUrl = Xrm.Page.context.getClientUrl();
var query = clientUrl +"/api/data/v8.0/opportunities(5e0f714-a0c6-e511-812b-061cb19131a3)?$select=rb_enddate,rb_startdate";
alert(query);
}
Since the new query doesn't have quotes around GUID, I'm unable to pass on the parentOpportunity dynamically.
Upvotes: 0
Views: 2597
Reputation: 3664
You want to strip off the curly braces, like this:
var query = clientUrl +"/api/data/v8.0/opportunities(" + parentOpportunity.slice(1, -1) + ")?$select=rb_enddate,rb_startdate";
As an aside, the CRM Rest builder is a great tool to help you construct REST queries.
Upvotes: 2