Hi,
I wanted to get count of open opportunities associated to an account.I am using below code and when executed the query in browser I don't see any error or any data returning. What is wrong with the code?
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/OpportunitySet?$select=Name&$filter=AccountId/Id eq (guid'"+acctId+"') and StateCode/Value eq 0", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState === 4) {
this.onreadystatechange = null;
if (this.status === 200) {
var returned = JSON.parse(this.responseText).d;
var results = returned.results;
for (var i = 0; i < results.length; i++) {
var name = results[i].Name;
}
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
Thanks in Advance