While updating our D365 instance to use the unified interface we have also started replacing the older (javaScript) odata requests with the Xrm.WebApi. Just today i stumbled across the fact that for example the Xrm.WebApi.retrieveRecord does not appear to bring back the GUIDs of lookup fields on the entity eg primary contact on Account., this was not the case for the older odata call which i was trying to mimic to save time refracting my code. Can anyone recommend the beast approach.
Thank G
function oDataRetrieve(entityName, guid, columnSet, callbackHandler) {
var orgPath = Xrm.Page.context.getClientUrl();
var restEndPoint = orgPath + "/XRMServices/2011/OrganizationData.svc";
var retrieveRequest = new XMLHttpRequest();
retrieveRequest.open("GET", restEndPoint + "/" + entityName + "Set(guid'" + guid + "')?$select=" + columnSet, isAsync);
retrieveRequest.setRequestHeader("Accept", "application/json");
retrieveRequest.setRequestHeader("Content-Type", "application/json; charset=utf-8");
retrieveRequest.send();
......
** Replaced with ***
RetrieveRecord: function (entityName, guid, columnSet, callbackHandler) {
var apiParms = "?$select=" + columnSet;
Xrm.WebApi.retrieveRecord(entityName, guid, apiParms).then(
function success(result) {
// console.log("Retrieved values: Name: " + result.name);
// perform operations on record retrieval
callbackHandler(result);
},
function (error) {
// Something went wrong during the data retrieval
Xrm.Navigation.openErrorDialog({ message: error.message });
}
);
},