Get next case functionality for CRM Unified Service Desk

Last week I shared an approach for implementing next case functionality for Dynamics CRM so that users can get the "next" case to work from a queue just by clicking a button. In today's post I will show an easy way to add the same functionality to Unified Service Desk (USD), but as an added bonus the case will also open in a new session tab.

Before talking through the code and configuration elements in detail, let's take a look at exactly how the get next case button works in my USD demo instance.

I'm displaying the get next button in the left panel, but it can be displayed in any visible panel.
Get next case button in USD

Once I click the button, a new session is opened if a "next" case is found in the queue.
The

If no "next" case can be found, an alert message is displayed.
No

There are three elements to make this work:

  1. The custom workflow activity and custom action from my previous blog post.
  2. A USD-specific web resource to expose the button and open the "next" case record.
  3. USD configuration elements (hosted controls, action calls, etc.) to load the get next case web resource and handle its output.

Because there are no changes to the existing custom workflow activity or custom action, I'm not going to discuss those further in this post, but let's take a closer look at the other elements.

The web resource

In my previous post, clicking the "get next case" button searched a queue for a case and then generated a link for a user to manually click to open the case. To streamline the functionality in USD, I decided to modify the web resource to automatically open the case if one is found. If no case can be found in the queue, an alert message is displayed.

Because USD allows you to modify JavaScript logic as described in this MSDN post, I considered reusing my existing get next web resource from before, and adjusting the USD configuration to pop open the case record. Ultimately I decided it would be easier to just add a new "USD" version of the web resource, which is included in the CRM solution in the sample code at the bottom of this post. That web resource is almost identical to my previous version except for this section of code:

    //if a case is found
    if(caseId != '00000000-0000-0000-0000-000000000000') {
        var caseUrl = _server + "/main.aspx?etc=112&extraqs=&pagetype=entityrecord&id=%7b" + caseId + "%7d";
        ////display the case number as a hyperlink
        //$("#outputdiv").append("Case: " + caseNumber + "");
        //automatically open case record
        window.open(caseUrl);
    }
    else {
        //otherwise display a message that no "next" case could be found
        //$("#outputdiv").append("No next case found");
        alert("No next case found");
    }

The USD configuration

Once the web resource is ready, the following USD configuration records need to be created:

  1. Create a CRM page hosted control to display the get next button web resource. As mentioned above, I am displaying the web resource in the left panel, but it will work in any visible panel. Get next case button hosted control
  2. Create a CRM page hosted control to display the case session. Case session hosted control
  3. Create a session name session information record to display the case number on the session tab. This isn't strictly necessary, but it looks better than "new session." Case session name record
  4. Create an action call to load the button. As in my previous post, the queue id and assign/remove from queue flags are supplied as encoded query string parameters. I've hardcoded the queue id, but you could use some sort of logic to dynamically set it. Also, you'll note the image here shows the assign and remove from queue flags set to false. Load get next action call
  5. Add the action call to the global manager DesktopReady event. Global manager DesktopReady event
  6. Create a window navigation rule to display case (incident) records opened from the get next case button hosted control in the case session tab. Open case from get next window navigation rule
  7. (Optionally) Update any agent scripting configuration to handle cases being loaded in session tabs. In my USD configuration I already had agent scripting configured for accounts per this USD walkthrough, so I created agent scripting for case sessions, too. Case agent script Load case script action call Case session tab BrowserDocumentComplete event
  8. Finally you need to add all of these elements to the USD configuration record.

Wrapping up

You can download a CRM solution with the custom assembly, custom CRM action and web resources from my Crm-Sample-Code repository on GitHub, but you'll have to do the USD configuration on your own.

What do think about this approach? Could you see yourself using it in your CRM projects? Let me know in the comments!

comments powered by Disqus