Monday, March 28, 2016

Dynamically Create HTML table in Dashboard in MS CRM 2015/16

<html><head>
 <title>Test</title>
 <meta><meta><meta><meta><meta><meta><meta></head>
 <body style="word-wrap: break-word;">
 <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
 <script src="../WebResources/aac_sdk_jquery_1.9.1.min" type="text/javascript"></script>
 <script src="../WebResources/aac_SDK_REST" type="text/javascript"></script>
 <script src="../WebResources/aac_JavaScriptRESTDataOperations" type="text/javascript"></script>
<script type="text/javascript">
function getphonecall()
{
var currentUserID = Xrm.Page.context.getUserId();

if(currentUserID != null)
{

var serverUrl = Xrm.Page.context.getClientUrl();
//alert(serverUrl);

var oDataEndpointUrl = serverUrl +"/XrmServices/2011/OrganizationData.svc/";

oDataEndpointUrl+="PhoneCallSet?$select=StateCode,ActivityTypeCode,CreatedBy,Description,DirectionCode,ScheduledEnd,OwnerId,PhoneNumber,PriorityCode,RegardingObjectId,Subject";

var service = new ActiveXObject("MSXML2.XMLHTTP.3.0");

if(service != null)
{
service.open("Get",oDataEndpointUrl,false);
service.setRequestHeader("X-Requested-Width","XMLHttpRequest");
service.SetRequestHeader("Accept","application/json,text/javascript, */*");
service.send(null);
var requestResults = eval('('+service.responseText +')').d.results;
var tableData = "";
if(requestResults != null && requestResults.length >= 1)
{
for(var i = 0;i<requestResults.length;i++)
{
//var accountEntity = requestResults[i];
//alert(accountEntity.Subject);
 var service = requestResults[i].Subject;
  if (service != null) {
                        //dynamically add table data with Service Names
                        tableData = tableData + "<tr><td>" + service + "</td></tr>";

                    }
}
 var table = "<table style='font-family:Segoe UI;font-weight:normal;font-size:13px;'><tr style='height:20px'><td style='text-decoration:underline;'><b>Subject</b></td></tr>" + tableData + "</table>";
                //show table data on the Account form
                //window.document.writeln(table);
$("#dashboardContainer").append(table);
}
}
}
}

 </script>
 <style>
 h5 {
 font-family: Segoe UI,Tahoma,Arial;
 font-weight: bold;
 font-variant: normal;
 color: #000080;
 text-decoration: underline;
 }
 p {
 font-family: Segoe UI,Tahoma,Arial;
 font-size: 13px;
 }
 </style>
 <table>
 <tbody>
 <tr><td><p id="Phone call"></p><br></td></tr>
 <tr><td> <br></td></tr><tr>
 <td><button onclick="getphonecall()">Click here</button></td></tr>
 </tbody></table>
 <span id="refreshSpan">&nbsp;&nbsp;</span>
    <br>
    <span id="clientDropdown"></span>
    <br>
    <div id="dashboardContainer" style="width: 100%; white-space: nowrap;">
    </div>
 </body></html>

Hope this help!!

No comments:

Post a Comment

Get files of last hour in Azure Data Factory

  Case I have a Data Factory pipeline that should run each hour and collect all new files added to the data lake since the last run. What is...