
hello,
I want to add activities records such as email,phone calls, task, appointment etc. on custom calendar date. I will write code for this but the data only shows particular one data on date . for example, Suppose the phone calls created on 10-10-2017 then the phone calls information display on 10 oct. 2017. Their data will be displayed by query web api, i write code for this help for modification in code or add code.
/* Crm Calendar */
<html>
<style>
table {
border: 1px solid #000000;
border-collapse: collapse;
text-align: center;
width: 79em;
background-color: LightGrey;
font-family: 'Times New Roman';
}
td {
border: 1px solid #000000;
height: 5em;
width: 5em;
padding: 5px;
vertical-align: top;
}
div.scroll {
background-color:grey;
width: 50px;
height: 50px;
overflow: hidden;
}
dival {
padding: 15px;
border: solid 2px steelblue;
}
th, table {
font-family: Times New Roman;
background-color: lightgrey;
}
td:hover {
cursor: pointer;
background-color: orange;
}
.alignclass {
align:right;
}
.day {
text-align: left;
}
.wid {
padding: 0.8em;
height: 5%;
}
.seco {
padding: 0.3em;
height: 10%;
}
.today {
background-color: #ECE;
}
</style>
<head>
</head>
<body>
<script>
function retrieveEntityActivity()
{
var clientURL=window.parent.Xrm.Page.context.getClientUrl();
var req = new XMLHttpRequest();
req.open("GET", clientURL + "/api/data/v8.2/activitypointers?$select=subject,actualstart,actualend,activitytypecode&$filter=createdon eq 2017-09-27T05:22:52Z", true);
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.setRequestHeader("Prefer", "odata.maxpagesize=10");
req.onreadystatechange = function ()
{
if (this.readyState === 4)
{
req.onreadystatechange = null;
if (this.status === 200)
{
var results = JSON.parse(this.response);
for (var j = 0; j < results.value.length; j++)
{
var resData=results.value;
var subject = resData[j]["subject"];
var activitytypecode = resData[j]["activitytypecode"];
var createdon = resData[j]["createdon"];
var createdon_formatted =resData[j]["createdon@OData.Community.Display.V1.FormattedValue"];
var actualstart=resData[j]["actualstart"];
var actualstart_formatted =resData[j]["actualstart@OData.Community.Display.V1.FormattedValue"];
var actualend=resData[j]["actualend"];
var actualend_formatted = resData[j]["actualend@OData.Community.Display.V1.FormattedValue"];
document.getElementById("demo1").innerHTML =activitytypecode;
}
}
else
{
alert(this.statusText);
}
}
};
req.send();
}
var date = new Date();
var month = ['JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY', 'JUNE', 'JULY', 'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 'DECEMBER'];
var y = date.getUTCFullYear();
var m = date.getUTCMonth();
var d = date.getUTCDate();
function preyear()
{
y = y - 1;
calendar();
}
function premonth()
{
m = m - 1;
calendar();
}
function nextmonth()
{
m = m + 1;
calendar();
}
function nextyear()
{
y = y + 1;
calendar();
}
function appoint()
{
window.open('';extraqs=&histKey=826371249&newWindow=true&pagetype=entityrecord#798989836','','status=0,resizable=1,width=1000px,height=600px');
}
function service()
{
window.open('';extraqs=%3fetc%3d4214&histKey=297367013&newWindow=true&pagetype=entityrecord#343053076','','status=0,resizable=1,width=1000px,height=600px');
}
function today()
{
y = date.getFullYear();
m = date.getMonth();
d=date.getDate();
calendar();
}
function calendar()
{
var html = "";
html += "<table style='background-color:#FDEBD0' border=1><tr><button onclick='appoint()'>+ Appointment</button><button onclick='service()'>+ Service Activity</button><br></tr><p style='padding-left:35em'><b>' + month[m] + ' ' + y + '';
html += "<tr><td class='wid' colspan='8'><button value='preyear' onclick='preyear()'><<<button value='premonth' onclick='premonth()'><<button value = 'today' onclick = 'today()' name='Today'>Today<button value = 'nextmonth' onclick='nextmonth()'>><button value = 'nextyear' onclick = 'nextyear()'>>></td></tr>";
html += "<tr><th>Sunday</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th></tr>";
html += "<input type=date>"
html += "<button><a href=''>Day</a></button><button><a href=''>Week</a></button><button><a href=''>Month</a></button>";
html += "<tr>";
for (var i = 1; i < 36; i++)
{
var firstDate = new Date(y,m,1);
var lastDate = new Date(y,m+1,1);
days = new Date(y, m, i - firstDate.getDay());
if (days.toDateString() == date.toDateString())
{
html += "<td class='day' onclick='retrieveEntityActivity()' style=background-color:grey><b>'+days.getDate()+'</a></td>';
}
else
{
html += "<td class='day' onclick='retrieveEntityActivity()'><b>"+days.getDate()+"<br><a id='demo1'></a></</td>";
}
if (i % 7 == 0)
{
html = html + "<tr></tr>";
}
}
html += "</tr></table>";
document.body.innerHTML = html;
}
calendar();
</script>
</body>
</html>
the data display on 1 oct. but the actual date of phone call is 27-09-2017 so the data display on that date
thanx in advance ,...
*This post is locked for comments
I have the same question (0)