Error -Newtonsoft.JsonJsonSerializationException: Self referencing loop detected for property ‘Entity’ …while setting Icons and ToolTips to the Columns in System Views -MS CRM

What is the Issue?

Microsoft Dynamics CRM provided the feature to set Icons and tooltips to the columns in System views based on some conditions like priority task, critical records, Expiry Dates on records, etc. This helps user to take action on or analyze the records.

But sometimes it simply fails and throws exception before loading the view itself. It becomes difficult to figure out issue behind this.

The Reason-

In earlier version of MS CRM i.e. previous to v9.1 where Microsoft provided the feature to add the icons and tooltips to columns, this is working fine for system views of all the entities except Activity entities like email, appointments, Tasks.

The reason behind this is the Party list fields used in entities which are also used in views. Party List fields are lookup fields of multiple entities.

Let’s have an example-

We have the “All Emails” system view for Email entity which is Activity entity.
In system view , there are two fields “From” and “To” as below-

setIcon3

Let’s add javascript on some field to show the icons and ToolTips-

SetIcon7

And publish the Customizations.
When We try to load the view got error message as belows-

setIcon4

When I downloaded the Log file I got some exact error like-

setIcon5

Even If you try to debug the function, you will not be able to do so. It shows exception before hitting the function. So if you take a look closely to the exception from log file it is showing some Error highlighted in above screenshot.

And here you have exact reason-

'from_Value[0].EntityType.Metadata.PrimaryKey'.

From field is Party List field and System is trying to set metadata value for entity of lookup and MS CRM is failing to parse the rowData for this multi-entity type lookup.

Solution-

Only you can remove the all party List columns from system view to make your javascript work for setting Icons and Tool Tips. (This will not the great solution which makes you view useless). So there is no OTHER solution to resolve this issue in earlier versions of MS CRM.

In latest version of MS CRM i.e. V9.1 and above MS has resolved this bug and you can see this working in new versions on MS CRM-

SetIcon2

You can see the “from” and “to” fields are ignored in these views.
Below is the Json rowData value where you can find the blank values for “from” and “to” fields-

SetIcon1

So the issue resolved in latest versions of MS CRM.

Hope this will help you.

Enjoy MS CRM!!!

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

New Unified Interface of MS Dynamics 365 CRM – Change Behavior to Classic Mode

What is the Issue?

New User interface of Ms Dynamics CRM(V9.1) with Unified Interface is bit confusing. Navigation is becoming very easy but bit complex for all the developers. Developers have much struggle to find the settings and many other options in MS CRM which was very easy to get through site map. Developers are not very much used to this behavior of the CRM. So, the question here is “where is Classic version of CRM?”

The Reason-

With new releases of MS Dynamics CRM 9.1 Microsoft is forcing the user to use Unified interface for all the apps installed in the MS CRM. Microsoft is providing the some new feature along with this Unified Interface.

Solution-

You can choose the behavior of your CRM application as Unified Interface or Classic CRM (developer is very familiar to). You need to change some setting of your application-

  1. When you are creating new online version you are getting redirected to MS Dynamics 365 My Apps.
  2. Also if you trying to hit the URL https://Orgname.crm.dynamics.com and opening app under My Apps (Sales,Sales Hub, Dynamics 365 – Custom), You are not able to see the classic mode of MS CRM. It is showing Unified Interface as below-
    UI01
  3. Login to the URL https://admin.powerplatform.microsoft.com with your MS Dynamics administrator credentials. You will be redirected to window below-
    UI02
  4. Click on Environments on Left hand side Navigation. It will show all your environments.
  5. Select environment( MS CRM Organization Name) and click on Settings on command bar.
  6. Under Product Section – > Click on Behavior –
    UI04
  7. Set Open in Classic Mode -> On
    UI05
  8. Save your Setting.
  9. Login to your CRM Organization by using our traditional way –
    https://orgname.crm.dynamics.com
  10. You will be able to see your classic mode of MS CRM now with all the features you are familiar with-
    UI06

 

Continue with your development with classic mode…

Enjoy Ms CRM!!!

Change behaviour of + Button on subgrid(Add new/Add existing)

What is the Issue?

When you click on + Button on subgrid ,sometimes it opens new record and sometimes behaves like add existing by opening search box for existing records.

The Reason –

This behaviour of + button depends on the association between the entities. Adding new record will strictly associates records and add existing will allow you to associate records if required.

Solution-

To change the behaviour of the + button you need to change requirement level of the lookup field of the entity on which you have subgrid i.e. parent entity.

For example- you have 2 entities – AEntity and BEntity.

AEntity contains subgrid of BEntity.

On BEntity form we have lookup field- AEntityLookup

Now behaviour will be decided on requirement level of AEntityLookup field.

1. If requirement level : Business Required

Then it will behave as Add new record of BEntity.

This will also change behaviour of record level delete button as record delete.

2. If requirement level : optional/business recommended

Then it will behave as Add Existing record of BEntity.

This will also change behaviour of record level delete button as record remove.

Try it..

Happy coding…!!!