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!!!

Set “Look For” for particular entities in Multi-entity Lookup Field like party List

What is the Issue?

Developers got requirement once in his development career to set the lookup value with only some particular entities like he only needs “users”, “contacts” and restrict other entity’s records to be selected. But he/she have to implement this for some conditions like on change of some field value. But this kind of lookup always shows all the entities in lookup.

The Reason-

This lookup field shows all the entities as it’s default OOB behavior of the multi-entity Lookup (Party List).

 Solution-

You can handle this situation with the help of client side scripting (JavaScript).

Lets have Example-

I want to show only “Contact” and “User” records in “To”,”Cc” and “Bcc” fields (Party List) of Email Entity depending on “Email Behavior” option set field value.

SetLookupForEx1

I have 2 conditions here –

  1. Default E-Mail : should show all the entities records in lookup field as default behavior of field.
    SetLookupFor1
  2. E-mail To Contact or Users Only: should show only “Contact” and “User” entities records in lookup field and all others should be hidden.
    SetLookupFor3

Lets do it with Javascript here-

SetLookupFor2

Add function “filterOnLoad” at locations-
1. “onLoad” event of form with “Pass execution Context as first Argument” checked.
2. “onChange” event of “EMail Behavior” field with “Pass execution Context as first Argument” checked.

Publish your customization and here its done…

Please Note : for “From” field has different behavior than these all above fields. “From” field is lookup/PartyList for only “Users” and “Queues”.
SetLookupFor4

 

You can refer My other blog post related to this one – Filter Required/Regarding (partylist data type) fields…

Hope this will help you.

Enjoy MS CRM!!!

Xrm Object Model v9.0 and greater

What is the Issue?

As of February 2017, the SDK extensions for Microsoft Dynamics 365 is deprecated, and won’t be supported in future releases of Dynamics 365, version 9.0 and beyond.

The Reason-

These extensions were added in Dynamics CRM 2013 to provide a simplified connection class, strong type generation for solutions, and web portal capabilities. These have been replaced with newer capabilities.

Solution-

The Xrm client APIs are deprecated in the current release to reorganize the Xrm client API object model to better align with the need of using the same client scripts without having to change them based on the context or the client (web client or the new Unified Interface) where they run. You should plan to use the new client APIs mentioned in the Replacement Client API column instead of the deprecated ones.

Following is the comparison for old Xrm Object Model and new one.-

Old Xrm Object model-

OldXrm

This Old Xrm Object Model is replaced with the below one-

FormContext

The Important change is Xrm.Page.Context is replaced with formContext i.e. executionContext.getFormContext.

Let’s see the example for new Xrm –

FormContextCode

For the information about environment we were using Xrm.Page.Context which is now replaced with Xrm.Utility.getGlobalContext.

We have 4 new namespaces for new Client APIs-
1. Xrm.Device
2. Xrm.Encoding
3. Xrm.Navigation
4. Xrm.WebApi

Also for your information below are some of the deprecated Client APIs with their replacements-

XrmObject

Enjoy Ms CRM!!!