Calendar and Calendar Rules in MS CRM

What is the Issue?

Calendar is the great feature provided by MS CRM which is used by the scheduling system to define when an appointment or activity is to occur. But when it comes to be used by other entities in case of calculation of dates which will consider the holidays and weekends , it becomes difficult to handle. OOB there is no option to use calendar directly in entities.

The Reason-

Calendar is only entity directly available in MS CRM to be used by developers, You will not be able to access Calendar Rules entity type record which holds the information of free/busy times for a service and for resources or resource groups, such as working, non-working, vacation, and blocked.

 Solution-

As there is no Out-Of-Box option, You need to go with custom code.

First let’s understand the calendar, Holidays Calendar and Calendar Rules-

You will find the calendar under Setting > Service Management >Customer Service Schedule. You can follow the below screens to configure your Business calendar-
Calender1

You can create Calendars as below with work days, work Hours and Holidays details .
This is the main calendar (with type 1) which is used to consider weekend and work hour in activities and appointments.
Calender2

Holiday Schedule has a lookup for another calendar entity record with type 2 i.e. Holiday Scheduler calendar.
Calender3

You have to create this Holiday calendar as below-Calender4Calender5

You can configure multiple holidays here-
Calender6
Calender7

There is Calendar Rule entity record associated with the Calendar entity ( Service Schedule and Holidays Schedule calendar) which holds information inside calendar like week days , Work Hour and Holiday start , holiday end, etc.

Now coming to the solution for our issue-

As we have the option for custom code,

And In case of c# code- we can use entity  “calendar” and “calendarrule” like-
Entity calendar= new Entity(“calendar”);
Entity calendarRule= new Entity(“calendarrule”);
And use OrganizationService object to play around calendar.

In case of javaScript, we can access the information using WebApi like
[organization URI]/api/data/v9.1/calendars
Use WebApi methods GET, POST, PATCH and DELETE operations.

[organization URI]/api/data/v9.1/calendarrules
It is not possible to perform GET, POST, PATCH and DELETE operations with this entity. This can be retrieved along with Calendar WebApi call, as a sub entity record.

You can refer the below code for javaScript to retrieve the Calendar and Holiday Schedule information-

Calender8

 

Hope this will help you to play with calendar.

Enjoy MS CRM!!!

2 thoughts on “Calendar and Calendar Rules in MS CRM

    • No, there is no direct way provided to create/update using Web API as It is not possible to perform GET, POST, PATCH and DELETE operations with this entity
      But with plugins i.e. server side code you can manage to update/create calendar rules.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s