Hi, how do i put my CRM Rest query into a JavaScript function to return the field 'default role'?
So far I have the following, and the default role is a lookup to the 'Bookable Resource Category' entity.
var req = new XMLHttpRequest(); req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/msdyn_projectteammembersignups(AE55156F-0D32-E811-A972-000D3A1A7A9)?$expand=msdyn_BookableResource($select=rev_defaultrole)", 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 msdyn_projectteammembersignupid = result["msdyn_projectteammembersignupid"]; if (result.hasOwnProperty("msdyn_BookableResource")) { var msdyn_BookableResource_rev_defaultrole = result["msdyn_BookableResource"]["rev_defaultrole"]; } } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send();