Accessing Dynamics Queues Programmatically

I typically still code in Dynamics using LateBound requests.  There have been a few instances where I have switched to Early Bound but I continue to do this for the following reasons

  1. I don’t like dragging around proxies into my code that can change environment to environment.
  2. When not depending on proxies, I feel have more options to downgrade my code into different versions based on what can be discovered.
  3. I get to learn about all the hidden relationships between entities and attributes that gives me a deeper understanding of what lies beneath.

With that said, this week I needed to access some queues in Dynamics and see what was in them.

To do this, I queried Dynamics for my queue based on the name provided.

QueryExpression query = new QueryExpression();
query.EntityName = "queue";
query.ColumnSet = new ColumnSet(true);
query.Criteria.AddCondition("name", ConditionOperator.Equal, "MySuperQueue");

EntityCollection entityResults = _CrmService.RetrieveMultiple(query);

From here, I was then able to query the queue for what it contains.

if (entityResults.Entities.Count == 1)
_CrmQueue = entityResults[0];

_QueueId = new Guid(_CrmQueue["queueid"].ToString());

QueryExpression queryQueues = new QueryExpression();
queryQueues.EntityName = "queueitem";
queryQueues.ColumnSet = new ColumnSet(true);
queryQueues.Criteria.AddCondition("queueid", ConditionOperator.Equal, _QueueId);

EntityCollection entityQueues = _CrmService.RetrieveMultiple(queryQueues);

foreach (Entity ent in entityQueues.Entities)
System.Diagnostics.Debug.WriteLine("ENTERED ON: " + ent["enteredon"].ToString());
if (ent.Contains("workeridmodifiedon"))
System.Diagnostics.Debug.WriteLine("BEING WORKED ON: " + ent["workeridmodifiedon"].ToString());


I’ll write another post on how to add an item to a queue, because that prevented some logic and general understanding of queues headaches that through me for a loop.

The key fields I want to highlight here are enteredon and workeridmodifiedon (both returning datetime values.  If you are managing a queue, enteredon is the datetime that the item was added to the queue and workeridmodifiedon is the much more important value that shows when the item as picked to be worked on.

A sad fact about Dynamic/CRM queues – all those fancy actions of Pick/Remove/Release – do not change the state of the queueitem in Dynamics which can present for some interesting challenges (a topic for another post).  I have to believe that interfacing with queues would be that much more robust if the status reasons changed as a result.

For now, now you know how to access the items in your queue from your own code.

Getting Started with the USD

If you have not used the USD in Dynamics365 then you’re missing out.

If you’re stuck on how to get started the process is relatively simple and primarily involves downloading the framework and deploying it to your tenant.

To start, download the require components – you will need the framework geared to your OS as well as the Package Deployer- which are all available here –

If you try to open the USD without running the Package Deployer, you’ll receive the following error.


When you execute the Package Deployer, it will ask you where you want to deploy the USD’s solution files to.


Next you’ll need to selection which package you want to import.  For now – go with the “New Environment” package.


Once selected, you’ll wait for the solutions to be installed.


Followed by all the post execution tasks to be executed.Dynamics6

Now if you go back and click the USD icon on your desktop, you’ll get this wonderfully empty canvas from which you can start implementing your solution.


For now though, you are ready to go.