|
Wehn building integration pieces, using the Webservice interface its sometimes useful to be able to page through the logged in users Work in Progress Queue to either process the items in there, or assign them to another Queue.
The code below takes the CrmService obtained when you log in, and returns a GUID value of the current users queue. If no Queue is found, or in the event more than 1 is returned it returns an empty Guid.
public static Guid GetWipQueueId(CrmService crm) { try { WhoAmIRequest request = new WhoAmIRequest(); WhoAmIResponse user; { user = (WhoAmIResponse)crm.Execute(request); } QueryByAttribute query = new QueryByAttribute(); query.EntityName = EntityName.queue.ToString(); query.Attributes = new string[] { "primaryuserid", "queuetypecode" }; query.Values = new string[] { user.UserId.ToString(), "3" };
RetrieveMultipleRequest retrieve = new RetrieveMultipleRequest(); retrieve.Query = query; retrieve.ReturnDynamicEntities = true; RetrieveMultipleResponse retrieved = (RetrieveMultipleResponse)crm.Execute(retrieve); BusinessEntityCollection Qs = retrieved.BusinessEntityCollection; if (Qs.BusinessEntities.Length == 1) { DynamicEntity de = (DynamicEntity)Qs.BusinessEntities[0]; KeyProperty property = (KeyProperty)de.Properties[0]; return property.Value.Value; } else { return Guid.Empty; } // return a blank just in case } catch (SoapException e) { throw new Exception("GetWipQueueId\nUser:" + "Serviceuser" + "\n" + e.Detail.InnerText.ToString()); } }
|
01 December 2009 IB
Microsoft Dynamics CRM
|
Back To List
Did this article answer your question |
 |
Yes |
 |
No |
|
Other items of interest in our knowledgebase
|