web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How I added Activity Entity Records on Calendar date dynamically using web api?

(0) ShareShare
ReportReport
Posted on by 775

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>

 adewd.PNG

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)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans