Record in Multiple Queue Error in CRM 2011

While looking at Queue Item Details we were getting Error

Error:

“This record is in multiple queues. Go to specific queue to view details.”

Cause:

On doing the repro steps it was realized that this is the message that we get when a case is reactivated after being closed.

This is because a queue item related to same case is already there in CRM in deactivated state.

Resolution:

To resolve this we wrote a plugin to reactivate the queue item and assign it to a next level queue based on business logic.

Source Code to Reactivate Queue Item (Entity) in CRM 2011

[sourcecode language=”csharp”]

var entityMoniker = localContext.PluginExecutionContext.InputParameters[“EntityMoniker”] as EntityReference;

var incidentid = entityMoniker.Id;

QueryExpression query = new QueryExpression();

query.EntityName = “queueitem”;

query.ColumnSet = new ColumnSet();

query.ColumnSet.Columns.AddRange(new string[] { “statecode”, “statuscode”, “queueitemid” });

query.Criteria = new FilterExpression();

query.Criteria.AddCondition(“objectid”, ConditionOperator.Equal, incidentId);

query.Criteria.AddCondition(“statecode”, ConditionOperator.Equal, 1);

EntityCollection results = serviceContext.RetrieveMultiple(query);

if (results != null && results.Entities != null && results.Entities.Count > 0)

{

SetStateRequest setQueueItemState = new SetStateRequest();

setQueueItemState.EntityMoniker = new EntityReference(“queueitem”, results.Entities[0].Id);

setQueueItemState.State = new OptionSetValue(0);

setQueueItemState.Status = new OptionSetValue(1);

serviceContext.Execute(setQueueItemState);

}

[/sourcecode]

Repro Screenshots:

  1. Create case:

 

  1. Add it to queue


     

  2. Work On


     

  3. Resolve it


  4. Reactivate it:


  5. Add to queue Again


  6. Try to open queue item details.


     

     

    Error Message:

Leave a Reply

Your email address will not be published. Required fields are marked *