{"id":2216,"date":"2016-04-07T16:01:19","date_gmt":"2016-04-07T16:01:19","guid":{"rendered":"http:\/\/himbap.com\/blog\/?p=2216"},"modified":"2016-04-09T08:52:05","modified_gmt":"2016-04-09T08:52:05","slug":"using-pickfromqueue-in-dynamics-crm-sample-code","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=2216","title":{"rendered":"Using PickFromQueue in Dynamics CRM -Sample Code"},"content":{"rendered":"<p>I saw one question in <a href=\"https:\/\/community.dynamics.com\">CRM community <\/a>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\u2019s 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\u2019s basically the queue item routing, which we can do using <strong>Route <\/strong>button after selecting queue item like following. If you are new to Queues, I will suggest you to refer <a href=\"https:\/\/www.microsoft.com\/en-us\/dynamics\/crm-customer-center\/create-or-edit-a-queue.aspx\">this KB<\/a>.<\/p>\n<p><a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2016\/04\/Routefunction.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2016\/04\/Routefunction-300x93.png\" alt=\"Routefunction\" width=\"300\" height=\"93\" class=\"alignnone size-medium wp-image-2217\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2016\/04\/Routefunction-300x93.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2016\/04\/Routefunction-624x193.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2016\/04\/Routefunction.png 860w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>We can use this request when we want to handle this functionality from code using a custom application or may be let\u2019s say we are developing case management portal or similar portal. To use this request we can use below three properties:<\/p>\n<p><a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2016\/04\/queueproperties.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2016\/04\/queueproperties-300x38.png\" alt=\"queueproperties\" width=\"300\" height=\"38\" class=\"alignnone size-medium wp-image-2218\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2016\/04\/queueproperties-300x38.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2016\/04\/queueproperties.png 621w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nWe can get full properties details from <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/microsoft.crm.sdk.messages.pickfromqueuerequest.aspx\">here<\/a>.<\/p>\n<p>And here is the code to use this request:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n  try\r\n            {\r\n                IOrganizationService organizationService= GetCRMService();\r\n                \/\/Setup request\r\n                PickFromQueueRequest request = new PickFromQueueRequest();\r\n                request.QueueItemId =new Guid(&quot;GUID of the queueitem&quot;); \r\n                request.RemoveQueueItem = true;\r\n\r\n                request.WorkerId = new Guid(&quot;GUID of the user whom we want to assign&quot;); \r\n\r\n                organizationService.Execute(request);\r\n            }\r\n            catch (FaultException&lt;Microsoft.Xrm.Sdk.OrganizationServiceFault&gt; ex)\r\n            {\r\n\r\n                Console.WriteLine(ex.Detail.Message);\r\n            }\r\n<\/pre>\n<p>Stay tuned for more sample code !!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u2019s first understand the message, why we need it. As name suggests this message is used to pick item from queue and used&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=2216\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,5,6,8,275],"tags":[353],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2216"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2216"}],"version-history":[{"count":9,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2216\/revisions"}],"predecessor-version":[{"id":2228,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2216\/revisions\/2228"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}