Hi Harish,
I can suggest you to pass to guid as filter criteria if you want to filter multiple records else retrieve using rest web api on html page.
I'm sharing working lines of code which is working for me.
<html lang="en" xmlns="www.w3.org/.../xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<style>
#myTable {
border-collapse: collapse;
text-align: left;
}
#myTable th,
td {
padding: 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
#myTable tr:hover {
background-color: #f5f5f5;
}
</style>
</head>
<body style='word-wrap: break-word;' onload='createView();'>
<iframe id="txtArea1" style='display:none'></iframe>
<!--<input type="button" onclick="createView();" />-->
<meta http-equiv="x-ua-compatible" content="IE=9,IE=10,IE=11">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script src="sc_json2.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
function createView() {
debugger;
try {
var customerobject = new Array();
customerobject[0] = new Object();
var lookupItem = parent.Xrm.Page.getAttribute("contact").getValue();
if (lookupItem != null && lookupItem != "" && lookupItem != "undefined") {
var guid = lookupItem[0].id.replace('{', '').replace('}', '');
var x = document.getElementById("myTable").rows.length;
if (x > 1) {
var table1 = document.getElementById("myTable");
for (var k = x - 1; k > 0; k--) {
table1.deleteRow(k);
}
}
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.0/incidents?$select=caseorigincode,_contactid_value,complaintstatus,_ownerid_value,contact_value,createdon,vendor_name_account_value,title&$filter=contact_value eq " + guid, false);
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=\"OData.Community.Display.V1.FormattedValue\"");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var results = JSON.parse(this.response);
if (results.value.length > 0) {
for (var i = 0; i < results.value.length; i++) {
var title = results.value[i]["title"];
var caseorigincode = results.value[i]["caseorigincode"];
var caseorigincode_formatted = results.value[i]["caseorigincode@OData.Community.Display.V1.FormattedValue"];
var complaintstatus = results.value[i]["complaintstatus"];
var complaintstatus_formatted = results.value[i]["complaintstatus@OData.Community.Display.V1.FormattedValue"];
var contact_value = results.value[i]["contact_value"];
var contact_value_formatted = results.value[i]["contact_value@OData.Community.Display.V1.FormattedValue"];
var table = document.getElementById("myTable");
var j = 0;
j = i + 1;
var row = table.insertRow(j);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
var cell5 = row.insertCell(4);
var cell6 = row.insertCell(5);
var cell7 = row.insertCell(6);
var cell8 = row.insertCell(7);
cell1.innerHTML = j;
if (title != null && title != 'undefined')
cell2.innerHTML = title;
if (createdon != null && createdon != 'undefined')
cell3.innerHTML = createdon.getDate() + "-" + createdon.getMonth() + "-" + createdon.getFullYear();
if (contact_value_formatted != null && contact_value_formatted != 'undefined')
cell4.innerHTML = contact_value_formatted;
if (vendor_name_account_value_formatted != null && vendor_name_account_value_formatted != 'undefined')
cell5.innerHTML = vendor_name_account_value_formatted;
if (caseorigincode_formatted != null && caseorigincode_formatted != 'undefined')
cell6.innerHTML = caseorigincode_formatted;
if (complaintstatus_formatted != null && complaintstatus_formatted != 'undefined')
cell7.innerHTML =complaintstatus_formatted;
if (_ownerid_value_formatted != null && _ownerid_value_formatted != 'undefined')
cell8.innerHTML = _ownerid_value_formatted;
}
}
} else {
// alert(this.statusText);
}
}
};
req.send();
}
} catch (error) {
alert("Error occured in createView function... " + error.message);
}
}
</script>
<table id="myTable">
<tr>
<td style='font-weight:bold'>Sr No</td>
<td style='font-weight:bold'>Complaint Ref. No</td>
<td style='font-weight:bold'>Created On</td>
<td style='font-weight:bold'>Consumer Name</td>
<td style='font-weight:bold'>Name</td>
<td style='font-weight:bold'>Channel of Complaint</td>
<td style='font-weight:bold'>Complaint Status</td>
</tr>
</table>
<br>
</body>
</html>
Regards,
Pravin