Wednesday, May 29, 2013

Making a field appear twice on a CRM form


This is possible in CRM 2011 now without getting our hands dirty. When you go to the form to add the field you are shown the fields at the right most cornet of the form. There the fields are already filtered to show the ones you have not being used. Once you UN tick that you can select any field that has been already used on the form to another place on the same form.



Working with Date and Time Values in CRM 2011 Programmatically


Most of us working with CRM 2011 would have faced some issues working with CRM 2011 date time objects as they don’t represent the exact date time value that we see on CRM form.

This has been an issue when working with the programmatically as what we see as the date time value in the CRM form isn’t the value that is stored in the database for that field. The value we send gets converted and gets stored inside the date time field. When we check the record from CRM form, internally this value has got converted and we see the correct value. This is all good. But what happens when you want to get this field programmatically for one of our task. This is where we get the issue.

We came across an issue like this while working with one of our projects. We came up with the following solution to get around this issue.

·         We retrieve the user setting of the user who created the record.
·         Then we take the TimeZoneBias and TimeZoneDaylightBias fiels values from the user setting record and calculate the correct time from them.

UserSettings us = "Retreived user settings record";
DateTime dt = account.start_date.Value.AddMinutes(-Convert.ToDouble(us.TimeZoneBias));
dt = dt.AddMinutes(-Convert.ToDouble(us.TimeZoneDaylightBias));

The value is normally updated in the database in the CRM by adding users time zone minutes and deducting the day light saving value. We simply add them here to get the correct date and time. Simple ha!.....

CRM 2011 Error “Object of type 'Microsoft.Xrm.Sdk.Entity' cannot be converted to type...”


This error is coming up when you try to execute a linq query. After checking this out we found out how to resolve this.

What happens is that we create an organization proxy variable and then cast to service context object. Before you cast to service context object you need to enable proxy types in organization service proxy. You can use the code below to do that and that would prevent you from seeing the above error and getting your task done.

orgServiceProxy.EnableProxyTypes();

Retrieving Calendar of a Bookable Resource in Dynamics

There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible...