Items not being deleted from CRM 4.0 Queues

On April 9, 2008, in Dynamics CRM, by Mitch Milam

I ran into an issue this morning testing one of my CRM add-ons.  Basically, I was processing items from an inbound, email-enabled Queue within CRM. When the processing was completed, I delete the Queue item – but it still remained in the Queue.  You could not longer open it, and as far as CRM was concerned, it was "deleted," but it was still visible.

After digging around the Internet a bit, I found the answer to the issue, which seems to only appear if you have upgraded from CRM 3.0 to 4.0.

 

Step 1: Disable the t_update_queueitembase trigger

Using SQL Server Management Studio, open the CRM database and locate the QueueItembase table.  Expand the Triggers group.

Right-click on the t_update_queueitembase trigger and select Disable.

image

This will effectively turn off the trigger and future queue items will be removed as expected ( and the way CRM 3.0 functioned ).

Note: It does not appear that a fresh installation of CRM 4.0 has this trigger, which is probably why this procedure works.

But, that doesn't take care of existing queue records that where created and "deleted" before you disabled the trigger.  The next steps will correct that issue.

Step 2: Find semi-deleted queue records

Using SQL Server Management Studio, perform the following query on the CRM database:

select * from queueitembase
WHERE
QueueId = 'GUID for queue'
AND
DeletionStateCode = 0


 

Note: Replace GUID for queue with the GUID for the queue in question.

 

Step 3: Removing semi-deleted queue records

If any records are returned, you will need to perform the following query to clear them from the queue list:

UPDATE dbo.QueueItemBase
SET DeletionStateCode = 2
WHERE
QueueId = 'GUID for queue'
AND
DeletionStateCode = 0

 

Note: Replace GUID for queue with the GUID for the queue in question.

This will change the status to "deleted" and remove them from the queue.