Table alias alias name is not unique when opening certain views in Microsoft Dynamics CRM 2011

This article provides a solution to an issue where you may be unable to open views after Microsoft Dynamics CRM 2011 Update Rollup 12.

Applies to:   Microsoft Dynamics CRM 2011
Original KB number:   2907665

Symptoms

A user may be unable to open views after Update Rollup 12. This issue happens when views of type Advanced Find View are modified to have fields from related entities added to the display column. Issue is identified both with Out Of Box or custom entities.

Cause

While modifying the view, the link-entity node is available twice. But for a single type of link-entity node, it must be available only once.

Resolution

Installing Microsoft Dynamics CRM 2011 Update Rollup 15 resolves the issue for the views that are modified after installing Update Rollup 15. The existing views identified before installing Update Rollup 15 throwing the error need to be fixed manually.

Here's an example showing how to fix the issue on an existing broken view:

It's how to reproduce the issue:

  1. Navigate to Settings, select Customizations, select Customize the System, point to Entities, select Account, and select View.
  2. Open Account Advanced Find View and select Add Columns.
  3. Select Primary Contact (Contact) related entity in Record Type dropdown.
  4. Check the checkbox next to Full Name and select OK.
  5. Select Save and Close.
  6. Select Publish all Customizations.
  7. Open Inactive Accounts view and select Edit Filter Criteria.
  8. Add/modify/delete any filter criteria (change Status = Inactive to Status = Active), select Ok and select Save and Close.
  9. Select Publish all Customizations.
  10. Again, in Inactive Accounts view, select Edit Filter Criteria and Add/modify/delete any filter criteria (change Status = Active to Status = Inactive).
  11. Select OK.
  12. Select Save and Close.
  13. Select Publish all Customizations.
  14. Go to Advanced Find and select Accounts in Look for: dropdown and select Inactive Accounts in Use Saved View dropdown.
  15. Select Results.

Here's how we fix it (Using the example above used to reproduce the issue):

  1. Launch CRM 2011 application.

  2. Navigate to Settings, point to Customizations, and select Solutions.

  3. Create a new solution and add Account entity to it without adding any dependencies.

  4. Now save the solution and export it as an unmanaged solution.

  5. Once the unmanaged solution zip file is saved, then extract the file.

  6. Open customizations.xml file in an XML editor like Visual Studio 2012 and select CTRL+M+M on the keyboard to collapse the full XML.

  7. Search for the view name that was throwing error. In this case, it's Inactive Accounts and it will be present only once in the whole file.

  8. It will expand only one saved query in the XML.

  9. In this section, expand <fetchxml> element and look for <Link-entity>.

  10. You'll see that following XML is duplicated:

    <link-entity name="contact" from="contactid" to="primarycontactid" visible="false" link- type="outer" alias="a_410707b195544cd984376608b1802904">
    
    <attribute name="fullname" />
    
    <attribute name="emailaddress1" />
    
    </link-entity>
    

    It should only be present one time.

  11. Remove one entry of this XML from customizations.xml file and save the changes.

  12. Now zip the files again with edited customizations.xml, [content_Types].xml and solution.xml.

  13. Import this zip file in to CRM application and publish all customization.

  14. It will fix the problem with Account Inactive Views. Which is how you can fix all the other views that are throwing this error.