Using PickFromQueue in Dynamics CRM - Sample Code

I saw one question in the CRM community forum today where a 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 and why we need it. As the name suggests this message is used to pick items 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 the following.
 
 

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

We can get full properties details from here.

And here is the code to use this request:

  1. try  
  2.           {  
  3.               IOrganizationService organizationService= GetCRMService();  
  4.               //Setup request  
  5.               PickFromQueueRequest request = new PickFromQueueRequest();  
  6.               request.QueueItemId =new Guid("GUID of the queueitem");   
  7.               request.RemoveQueueItem = true;  
  8.    
  9.               request.WorkerId = new Guid("GUID of the user whom we want to assign");   
  10.    
  11.               organizationService.Execute(request);  
  12.           }  
  13.           catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)  
  14.           {  
  15.    
  16.               Console.WriteLine(ex.Detail.Message);  
  17.           }  
Stay tuned for more sample code.
 

Up Next
    Ebook Download
    View all
    Learn
    View all