Hi,
I have a odata query which works fine mostly but not for some users. Here is the query snippet(a very simple and straight forward) which pulls user's county from user record.
var serverUrl = Xrm.Page.context.getClientUrl();
var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
var userRequest = new XMLHttpRequest();
userRequest.open("GET", ODataPath + "/SystemUserSet(guid'" + userId + "')", false);
userRequest.setRequestHeader("Accept", "application/json");
userRequest.setRequestHeader("Content-Type", "application/json; charset=utf-8");
userRequest.send();
if (userRequest.status === 200) {
var retrievedUser = JSON.parse(userRequest.responseText).d;
var county = retrievedUser.new_county;
return county;
}
else {
return "error";
}
Sometimes it does not retrieve 'County' or for some reason County field is blank. This script is added to run on 'OnLoad' of the form. There is a 'County' for the users that are having issue and I am sure. But not sure why it does not display on the form load. Is it because the response has been recieved? Or some slowness? Because it works fine for other users!
Someone please help me in troubleshooting this. Thanks for any help.