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


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);

}

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 comment

I’m Abhinav

Welcome to my Blog. I am a passionate architect and developer dedicated to creating innovative and user-friendly digital experiences. With a background in both design and development, I bring a unique blend of creativity and technical expertise to every project I undertake.

In addition to my technical skills, I have a keen interest in the latest industry trends and enjoy sharing my knowledge through blogging and speaking engagements. When I’m not coding or designing, you can find me exploring new technologies, reading about the latest in tech, or indulging in my love for music and travel.

Let’s connect