Knowledge found and lost while working with Microsoft Dynamics CRM
RSS icon Home icon
  • Items not being deleted from CRM 4.0 Queues

    Posted on April 9th, 2008 mitch Print Print 7 comments

    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.

    Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
    Loading ... Loading ...
    3,831 views
     

    7 responses to “Items not being deleted from CRM 4.0 Queues”

    1. Wonderful, this issue has been annoying the heck out of us! Good find, thanks.

    2. One extra note you should add, those records marked for deletion may take up to 24 hours to be removed….

    3. Thank you. mr Bacon saver !

    4. Thanks for that Mitch!

      I re-wrote the sql above to make it faster to find and deactivate the ghost email records. The following will find all "email" items in *any* queue (i.e. user queues too) where the associated email does not exist in the email table and update its status to deleted.

      UPDATE dbo.QueueItemBase
      SET DeletionStateCode = 2
      WHERE
      objecttypecode = '4202'
      and ObjectId not in (Select ActivityId from EmailBase)
      and DeletionStateCode = 0

    5. Via Regan Murphy:

      Microsoft has released a hotfix for this problem now
      http://support.microsoft.com/kb/948172/en-us

      Cheers
      Regan

    6. Did you delete the emails from the Queue using a Workflow? If so, how did you do it? I'd like to do that…

      thanks!
      Nathan

    7. Nathan,

      No, it's just assigning them so it will appear to be 'moved' from one queue to the other.

      Mitch

    Leave a reply