Using PickFromQueue in Dynamics CRM -Sample Code

I saw one question in CRM community forum today where user was looking for help to use PickFromQueue message, so I thought of writing sample code for the same, so that it can help others as well. Let’s first understand the message, why we need it. As name suggests this message is used to pick item from queue and used to assign to some user, so it’s basically the queue item routing, which we can do using Route button after selecting queue item like following. If you are new to Queues, I will suggest you to refer this KB.

Routefunction

We can use this request when we want to handle this functionality from code using a custom application or may be let’s say we are developing case management portal or similar portal. To use this request we can use below three properties:

queueproperties
We can get full properties details from here.

And here is the code to use this request:

  try
            {
                IOrganizationService organizationService= GetCRMService();
                //Setup request
                PickFromQueueRequest request = new PickFromQueueRequest();
                request.QueueItemId =new Guid("GUID of the queueitem"); 
                request.RemoveQueueItem = true;

                request.WorkerId = new Guid("GUID of the user whom we want to assign"); 

                organizationService.Execute(request);
            }
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)
            {

                Console.WriteLine(ex.Detail.Message);
            }

Stay tuned for more sample code !!

One thought on “Using PickFromQueue in Dynamics CRM -Sample Code

  1. Pingback: Using PickFromQueue in Dynamics CRM -Sample Code - Microsoft Dynamics CRM Community

Leave a Reply

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