Showing posts from July, 2016

Get count of Attachments for Email in Dynamics CRM without code

Recently we had a requirement from our customer to show the number of attachments for each email in a view. The number needs to be reflected whenever the user refreshes the view. Simple requirement right? And what is coming to your mind? Plugins? Workflows? Well if you are thinking of the Plugins and workflows, I am sure you are not alone. In fact the first thing that came to my mind was the same. But we are in CRM 2016 right? And is there no other way to achieve this? I brainstormed for sometime and then came up with the below solution. Believe me it is a simple solution without any code and I am pretty sure you would like it. No it is not rollup field. It is using the calculated field feature of Dynamics CRM. Let us first look at the email entity in CRM. A quick glance at the email entity and you could see there is field already in the email entity called  ‘Attachment Count’.  Wow! Can’t we use this field. Unfortunately the answer is ‘No’. If you open this field, it is a no

Date and Time field behavior in MS CRM

For CRM versions earlier than CRM Online 2015 Update 1 and CRM 2016 (on-premises), you cannot define the behavior of the date and time values. By default, the date and time values are stored as    UserLocal. But in latest version,  behavior of date and time field is classified as 3 types. UserLocal : ·          This behavior always stores the date and time in UTC format. While retrieving, it will returns date and time in UTC format. ·           When user trying to update date and time, if user enters date in UTC, system will update the value as it is or else it will convert entered date and time into UTC format then stores. ·           This behavior is used for system attributes like   CreatedOn  and   ModifiedOn , and cannot be changed. You should use this behavior for custom attributes where you want to store date and time values with the time zone information DateOnly: ·            This behavior will stores date only and time will be always stores as 12:00AM (00:00:00).

Improving MS CRM Performance

Performance on MS CRM is always a crucial thing and we may follow different ways to achieve the performance thing. Below is the one more approach we can improve the performance bit more. In IIS setting of a website where MS CRM is hosted, there we can change the Output Cache property. By changing this property to true, initially any entity record load may take bit time; later on it will open the records in much lesser time. This is quite a good approach to improve the performance. Below screenshot explains where to change the output Cache settings Open IIS, click on Microsoft Dynamics CRM site-> On Right side Panel click on Feature View-> Configuration Editor (source of below description: MSDN) What is omitVaryStart: Gets or sets a value indicating whether the   vary   header is enabled. Type:   System.Boolean true   if the   vary   header is enabled; otherwise,   false . The default is   false . The   vary   header indicates the request-header fiel

Upsert in MS Dynamics CRM

If we want to update a record in any entity, we should require GUID. If we know the GUID, we can do it easily, if not, we should retrieve the GUID of that record first, then we can update the record. Here, two database calls (Retrieve and Update) we are making which impacts performance of an application. In these scenarios, Upsert will be very useful. Upsert request will check in database whether record exists in database, if exists it will update the record or else it will create the record. So, how do we know that whether Upsert create or update record in each call? This information we can get from UpsertResponse which contains a Boolean property RecordCreated. If RecordCreated contains “true” it indicates Upsert created the record else updated the record. Sample Code:                Entity  testEntity =  new   Entity ( "new_test" );                 testEntity[ "new_test1" ] =  "test1" ;                 testEntity[ "