This documentation is archived and is not being maintained.

Monitoring Microsoft Dynamics CRM 4.0 Queues with a Windows Sidebar Gadget

Inna Agranov
Microsoft Corporation

June 2009


Learn how to use Microsoft Windows Sidebar gadget to monitor the information that is contained in Microsoft Dynamics CRM 4.0 queues.

The sample demonstrates how to write a custom application that uses SOAP messages to call Microsoft Dynamics CRM Web service APIs to retrieve the queue data.

Download the sample code for this article: CrmQueueGadget.

The Readme.doc that is included with the sample code contains information about how to install and run the sample application.

Applies To

Microsoft Dynamics CRM 4.0

Windows Vista


Microsoft Dynamics CRM 4.0 contains a rich set of Web service APIs that can be used by various types of applications. This sample application uses a Windows Sidebar gadget to retrieve and display the information that is contained in the Microsoft Dynamics CRM 4.0 queues of a currently logged-in user. The polling of data is performed at specified time intervals. Because the Windows Sidebar gadget is always available on the computer desktop, it is a perfect tool for displaying information that is frequently updated. Monitoring the content of the Microsoft Dynamics CRM Assigned and In Progress queues with the CRM Queue gadget fits well into this category. The Assigned and In Progress queues contain work items that frequently change and often require your immediate attention.

It is important to become familiar with Windows Sidebar programming before you install and run the sample application. You can find the information at

Queues in Microsoft Dynamics CRM

Microsoft Dynamics CRM queues are holding containers for activities that have to be completed. You can use queues to manage your activities, such as tasks, e-mails, or telephone calls. You can also use queues to manage cases that are created to handle customer service issues. There are two types of default queues: Assigned and In Progress. The Assigned queue contains active cases and activities that have been assigned to you, but that you have not yet accepted. This can include e-mail messages that you have received. The In Progress queue contains cases and activities that you have accepted and that you currently are working on. Your organization may create additional queues.

Using CRM Queue Gadget to Display Queue Content

To view Assigned or In Progress work items, you have to specify the user settings information in the fields that are provided by the CRM Queue gadget. This information includes the Microsoft Dynamics CRM server name (required field), the organization name, polling interval and queue type. To display the content of a specific queue, select Assigned or In Progress in the Queue type drop-down list.

The user settings information.


The following work items are retrieved from the Assigned queue.


The following work items are retrieved from the In Progress queue.


The Microsoft Dynamics CRM Queues form displaying work items that are contained in the In Progress queue.


Developing the CRM Queue Gadget Application

The following sections describe how to retrieve the data from the Microsoft Dynamics CRM queues by using SOAP messages and how to read and write the user settings data.

Retrieving Data from Microsoft Dynamics CRM

Windows Sidebar Gadgets are composed of HTML and JavaScript files. You can use an AJAX object in JavaScript to send custom SOAP request messages to the Microsoft Dynamics CRM server. To parse the response to SOAP request messages, use the Msxml2.DOMDocument DOM object. You do not have to process the SOAP messages asynchronously because the user is not blocked by the gadget application. To reduce the server load, retrieve only important information that you want to monitor.

The following code example shows how to build the SOAP request to retrieve the queue items and process the response.

// Create a RetrieveMultiple message request and receive a response 
// from the Microsoft Dynamics CRM server.
function getQueueItems(queueId)
    // Build the SOAP request for the RetrieveMultiple call.
    var request = '<soap:Body><RetrieveMultiple xmlns="">';
    request += '<query xmlns:q1="" xsi:type="q1:QueryByAttribute">';
    request += '<q1:EntityName>queueitem</q1:EntityName>';
    request += '<q1:ColumnSet xsi:type="q1:ColumnSet">';
    request += '<q1:Attributes>';
    request += '<q1:Attribute>title</q1:Attribute>';
    request += '<q1:Attribute>objectid</q1:Attribute>';
    request += '<q1:Attribute>objecttypecode</q1:Attribute>';
    request += '<q1:Attribute>priority</q1:Attribute>';
    request += '</q1:Attributes>';
    request += '</q1:ColumnSet>';
    request += '<q1:Attributes>';
    request += '<q1:Attribute>queueid</q1:Attribute>';
    request += '</q1:Attributes>';
    request += '<q1:Values>';
    request += '<q1:Value xmlns:q2="" xsi:type="q2:guid">' + queueId +'</q1:Value>';
    request += '</q1:Values>';
    request += '<q1:PageInfo>';
    request += '<q1:PageNumber>1</q1:PageNumber>';
    request += '<q1:Count>5</q1:Count>';
    request += '</q1:PageInfo>';
    request += '<q1:Orders>';
    request += '<q1:Order>';
    request += '<q1:AttributeName>enteredon</q1:AttributeName>';
    request += '<q1:OrderType>Descending</q1:OrderType>';
    request += '</q1:Order>';
    request += '</q1:Orders>';
    request += '</query>';
    request += '</RetrieveMultiple></soap:Body>';

    // Execute the RetrieveMultiple request.
    var response = executeRequest(request, "RetrieveMultiple");
    // Load the response XML into a DOM object.
    var oXml = loadXml(response);
    // Retrieve the business entities that are contained in the queue.
    var queueItems = oXml.documentElement.selectNodes("//soap:Body/RetrieveMultipleResponse/RetrieveMultipleResult/BusinessEntities/BusinessEntity");
    return queueItems;

Reading and Writing User Settings Using the Gadget Infrastructure

The gadget infrastructure provides APIs for reading and writing the user settings, such as the Microsoft Dynamics CRM server name, the polling interval, and the queue type.

The following code example shows how to read the user settings.

var currentServerName = System.Gadget.Settings.readString("crmServerName");

The following code example shows how to write the user settings.

var temp = serverName.value; 
System.Gadget.Settings.writeString("crmServerName", temp);

Additional Information

Send Us Your Feedback about this Article

We appreciate hearing from you. To send your feedback, click the following link and type your comments in the message body.

The subject-line information is used to route your feedback. If you remove or modify the subject line we may be unable to process your feedback.

Send Feedback