Thursday, June 27, 2013

The Timeline component for Microsoft Dynamics 2011

The company xRM Consultancy has developed a free component that can display activities in the timeline, and it can give a good overview of the Customer (Company or Contacts) or Opportunity activities.


I have noted the following advantages and disadvantages with this component:

Wednesday, June 19, 2013

Lazy fix of Infinite Loops in Plugins

Got an error stating that CRM has identified an infinite loop?

This usually means that the number of iterations reaches a maximum of 8. We can fix this by adding a depth check at the beginning of our plugin code, just after we initialize each of the service objects:

IPluginExecutionContext _context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory _factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
_sdk = _factory.CreateOrganizationService(context.UserId);
ITracingService _tracer = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

if (_context.Depth > 1) // if the plugin has run more than once
{
        // if so, executes a return statement to cancel out of the plugin
        return;
}

Now when we run the plugin, we shouldn’t run into an infinite loop.

NB: You must be careful when using the DEPTH property as there can be more complex scenarios that you may run into. 

CRM 2011 Database Backup

How to easily automate CRM database backup?
You can do it with help of SQL command or own console app.
You’ll need to backup the following CRM databases:

  • MSCRM_CONFIG
  • *_MSCRM

SQL command to backup a database is:

backup database <database name> to disk ='C:\Temp\backups\sql\<database name_timestamp>.bak'
      with format, name ='Full backup of <database name>'

To backup the database using a console program - use the code below:

using (SqlConnection conn = new SqlConnection(this.ConnectionString))
{
    string path = Path.Combine("C:\Temp\backups\sql\", string.Format("{0}_{1:yyyyMMdd_HHmmss}.bak",this.DatabaseName, DateTime.Now));

    SqlCommand cmd = new SqlCommand(
        string.Format(@"backup database {0} to disk ='{1}' with format, name ='Full backup of {0}'",
            this.DatabaseName, path), conn);

    cmd.CommandTimeout = 120;
    conn.Open();
    cmd.ExecuteNonQuery();
    conn.Close();
}
Done ;)

Tuesday, June 18, 2013

What’s not supported in the next major release of Microsoft Dynamics CRM (2013?)

Removal of the 2007 Endpoint and Legacy Features

The 2007 service endpoint was deprecated in the Microsoft Dynamics CRM 2011 release. Extensions that use the 2007 endpoint will not be supported and will not work in the next major release of Microsoft Dynamics CRM. Note the following more detailed information:

  • Microsoft Dynamics CRM Online customers using the Microsoft account identity provider can continue to use extensions that require the 2007 endpoint after upgrade. However, prior to the transition of your organization to Microsoft online services (MOS), you will need to upgrade or remove those extensions that require the 2007 endpoint.
  • Microsoft Dynamics CRM Online customers using the Microsoft online services (MOS) identity provider will see no change in service. The 2007 endpoint has not been supported in organizations using the MOS identity provider.
  • When Microsoft Dynamics CRM 2011 on-premises and IFD customers try to upgrade their server to the next major release of Microsoft Dynamics CRM, the upgrade process will detect extensions that are using the 2007 endpoint or legacy Microsoft Dynamics CRM 4.0 features. If any of these extensions are found, the Environmental Diagnostic Wizard will report an error and you will not be able to continue the upgrade until those extensions are removed or upgraded to use the 2011 endpoint.

The following legacy Microsoft Dynamics CRM 4.0 features will be removed or will no longer be supported in the next major product release:

Thursday, January 24, 2013

How to improve CRMAsyncService.exe memory and CPU usage.


The Microsoft CRM web site if hosted on a multi-processor/core server will automatically be using server Garbage Collection mode, but for managed Microsoft .Net programs like the CRMAsyncService.exe, they will default to the workstation garbage collection mode. Note that this resolution will only apply if Microsoft Dynamics CRM is installed on a multi-processor or multi-core server since the crmasyncservice will aways be forced to use the Microsoft .Net workstation garbage collection mode on a single CPU (non multi-core) server.

In order to allow the CRMAsyncService.exe to take advantage of all the processors/cores on a server, you can add the following element to a CRMAsyncService.exe.config file and place it in the same directory as the CRMAsyncService.exe program, typically in the “C:\Program Files\Microsoft Dynamics CRM\Server\bin” directory if you haven’t changed the default installation location for the Microsoft CRM Server.

Note that these changes will take effect the next time that you restart the Microsoft CRM Async Service.  Also note that if you already have a crmasyncservice.exe.config file, to place this information for the <gcServer enabled=”true”/> into the Runtime and configuration tags as seen below.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <runtime>
      <gcServer enabled="true"/>
   </runtime>
</configuration>

As with any changes, although this can give much better throughput for the Microsoft CRM Async Service and workflows able to be executed in a given time frame, it is best to measure the changes before and after implementing this change.  The CRM Async Service perfmon counters can be used for this as well as counters for Memory, .Net CLR Memory, and Processor.  There are also other factors such as customizations, workflows, and SQL Server performance that plays a factor in overall Microsoft CRM Async Service performance, but enabling gcServer mode is a great way to improve performance on multi-processor servers with minimal effort.