Continuing off my post of adding items to a queue programmatically, I wanted to add items to this queue (why else would I be using a queue?).
The code here is relatively simple and boring as I queried for a contact named Andrew, found him and added a new queueitem to the queue.
QueryExpression queryContact = new QueryExpression(); queryContact.EntityName = "contact"; queryContact.ColumnSet = new ColumnSet(true); queryContact.Criteria.AddCondition("firstname", ConditionOperator.Equal, "Andrew"); EntityCollection entityContacts = _CrmService.RetrieveMultiple(queryContact); EntityReference contactRef = new EntityReference("contact", entityContacts.Id); Entity q = new Entity("queueitem"); q["queueid"] = new EntityReference("queue", _QueueId); q["objectid"] = contactRef; _CrmService.Create(q);
The results were anything but.
The first time I executed this code it worked fine, created a new queueitem record and associated to my man Andrew.
The second time I executed this code, it exploded with the following message (which seems odd for a queue to do).