As you most likely know, CRM 2011 now allows you to delete Business Units. A client recently reported an issue that occurred when they attempted to delete a business unit. The error message displayed through the UI was:
“Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #E79AE80FDetail”
Since that didn’t provide me with enough information to effectively troubleshoot the issue I decided to run a trace on the server. The trace file provided additional insight:
Crm Exception: Message: Generic SQL error., ErrorCode: -2147204784, InnerException: Microsoft.Crm.CrmException: Generic SQL error. —> Microsoft.Crm.CrmException: Generic SQL error. —> System.Data.SqlClient.SqlException: The DELETE statement conflicted with the REFERENCE constraint “business_unit_queues”. The conflict occurred in database “CRMOrgDBName_MSCRM”, table “dbo.QueueBase”, column ‘BusinessUnitId’.
The statement has been terminated.
The above error indicates that the delete request could not be completed because there are dependencies that still exist on that Business Unit. However, we could not see the dependent records when opening the Business Unit and selecting the links from the left navigation menu. Instead, we had to take a different approach and the easiest way I found to resolve the issue was to take the following steps:
- Run the following query against the businessunit table
- Select businessunitid, name from businessunit where name = ‘name of business unit for deletion’
- Copy the businessunitid and use it in the following query
- Select name, description from QueueBase Where OwningBusinessUnit = ‘copied businessunitid’
After running the query we found several queues that were still referencing the Business Unit. Therefore, we first needed to open the queue, remove all items from the queue and then delete the queue. Below are the steps to complete that action:
- Go to Workplace, Queues and find each of the queues in CRM and take the action to remove or delete all items from each queue
- You can find the ‘Remove all Items’ action on the action menu
- Go to Settings, Business Management, Queues, find each of the Queues and delete each one
Now that all dependencies to the Business Unit are removed, you should be able to successfully delete the Business Unit.
- Go to Settings, System, Administration and delete the Business Unit
I hope this helps in the event you run into this issue.