Unable to Sort View Columns in Dynamics CRM 2011

Roshan Mehta, 23 August 2012

I encountered an interesting issue with the “My Open Leads” view in Microsoft Dynamics CRM 2011. The view was customized to include additional attributes from the Lead entity as well as attributes from related parent entities. When a User navigates to the view, it was sorted correctly but the User was unable to sort columns on demand by clicking on the column headings.  In this blog post, I will show you how to fix this issue by modifying the solution XML directly.

 Unable to Sort View Columns in Dynamics CRM 2011

The screenshot above shows how the view is configured. Notice that includes the Address 1: City column from the related Customer. By default, CRM will not allow Users to sort this column on-demand.

The customization area of Microsoft Dynamics CRM 2011 allows configurators to sort views for a maximum of two columns. This means that all Users that access the view will be the view sorted by a specific column by default, but they do have the ability to click on column headings to perform on-demand sorting. There is one exception – attributes defined as “Multiple Lines of Text” or attributes belonging to a parent entity are often unable to be sorted, and CRM manages this inside the solution XML.

In order to troubleshoot this issue, I created a new solution in CRM called “Lead Entity” which only holds the Lead entity and no other dependent components. I then exported this to my machine and opened up the solution XML.

I then searched for “My Open Leads” and examined the XML code. The part we are interested in is shown in the code snippet below:

  <grid name="resultset" object="4" jump="fullname" select="1" icon="1" preview="1">
    <row name="result" id="leadid">
      <cell name="fullname" width="300" disableSorting="0" />
      <cell name="subject" width="200" disableSorting="0" />
      <cell name="a_67943a93170746378c244c5dcbefbed9.address1_city" width="200" disableSorting="1" />

There are a few important things to notice here. The address1_city column has its disableSorting property set to 1. For some reason, CRM adds the same property to each of the other columns but sets the value to 0.

So how do we fix this? Simple! Remove the disableSorting property from each of the columns that have it set to 0. Re-zip the customization files and import the solution back into your CRM system. You will now be able to sort all columns on demand!