try {
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
fetchXml += "<entity name='opportunity'>";
fetchXml += "<attribute name='budgetamount' />";
fetchXml += "<attribute name='statuscode' />";
fetchXml += "<attribute name='opportunityid' />";
fetchXml += "<attribute name='name' />";
fetchXml += "<attribute name='createdby' />";
fetchXml += "<attribute name='ss_requesttype' />";
fetchXml += "<order attribute='name' descending='false' />";
fetchXml += "<filter type='and'>";
fetchXml += "<condition attribute='opportunityid' operator='in'>";
for (var i = 0; i < arrayVals.length; i++) {
var oppId = arrayVals[i].replace("{", "").replace("}", "");
fetchXml += "<value uitype='opportunity'>" + oppId + "</value>";
}
fetchXml += "</condition>";
fetchXml += "</filter>";
fetchXml += "</entity>";
fetchXml += "</fetch>";
var webapiPath = lXrm.Page.context.getClientUrl() + "/api/data/v9.1/opportunities?fetchXml=" + encodeURIComponent(fetchXml);
var service = new XMLHttpRequest();
service.open("GET", webapiPath, false);
service.setRequestHeader("Accept", "application/json");
service.setRequestHeader("Content-Type", "application/json; charset=utf-8");
service.setRequestHeader("OData-MaxVersion", "4.0");
service.setRequestHeader("OData-Version", "4.0");
service.setRequestHeader("Prefer", "odata.include-annotations=*");
//service.setRequestHeader("Prefer", "odata.maxpagesize = 3"); this tag isused to retrieve no of //records
service.send(null);
if (service.readyState == 4 /* complete */) {
if (service.status == 201 || service.status == 200) {
var result = eval('(' + service.responseText + ')');
if (result.value.length > 0) {
for (var i = 0; i < result.value.length; i++) {
var opportunityid = result.value[i].opportunityid;
var name = result.value[i].name;
var budgetamount = result.value[i].budgetamount;
var createdby = result.value[i]['_createdby_value@OData.Community.Display.V1.FormattedValue'];
}
}
}
}
} catch (ex) {
}
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
fetchXml += "<entity name='opportunity'>";
fetchXml += "<attribute name='budgetamount' />";
fetchXml += "<attribute name='statuscode' />";
fetchXml += "<attribute name='opportunityid' />";
fetchXml += "<attribute name='name' />";
fetchXml += "<attribute name='createdby' />";
fetchXml += "<attribute name='ss_requesttype' />";
fetchXml += "<order attribute='name' descending='false' />";
fetchXml += "<filter type='and'>";
fetchXml += "<condition attribute='opportunityid' operator='in'>";
for (var i = 0; i < arrayVals.length; i++) {
var oppId = arrayVals[i].replace("{", "").replace("}", "");
fetchXml += "<value uitype='opportunity'>" + oppId + "</value>";
}
fetchXml += "</condition>";
fetchXml += "</filter>";
fetchXml += "</entity>";
fetchXml += "</fetch>";
var webapiPath = lXrm.Page.context.getClientUrl() + "/api/data/v9.1/opportunities?fetchXml=" + encodeURIComponent(fetchXml);
var service = new XMLHttpRequest();
service.open("GET", webapiPath, false);
service.setRequestHeader("Accept", "application/json");
service.setRequestHeader("Content-Type", "application/json; charset=utf-8");
service.setRequestHeader("OData-MaxVersion", "4.0");
service.setRequestHeader("OData-Version", "4.0");
service.setRequestHeader("Prefer", "odata.include-annotations=*");
//service.setRequestHeader("Prefer", "odata.maxpagesize = 3"); this tag isused to retrieve no of //records
service.send(null);
if (service.readyState == 4 /* complete */) {
if (service.status == 201 || service.status == 200) {
var result = eval('(' + service.responseText + ')');
if (result.value.length > 0) {
for (var i = 0; i < result.value.length; i++) {
var opportunityid = result.value[i].opportunityid;
var name = result.value[i].name;
var budgetamount = result.value[i].budgetamount;
var createdby = result.value[i]['_createdby_value@OData.Community.Display.V1.FormattedValue'];
}
}
}
}
} catch (ex) {
}