Dynamics CRM offers sophisticated tools for working with cases and service queues, but sometimes users just want a quick and simple way to get the next case to work. In today's post, I'll share an easy way to implement this functionality in your Dynamics CRM organization.
There are three components to my approach:
- First, there is a custom workflow activity that searches a queue for unassigned cases and assigns the one that entered the queue earliest to a user. This activity returns the assigned case id and case number as output parameters.
- Second, there is a CRM action that that acts as a wrapper for the custom workflow activity.
- Finally, there is a web resource that displays a button to call the CRM action and generate a link to the assigned case (or a message if there are no cases in the queue to assign).
Let's look at each of these pieces in more detail. If you'd rather get right to the code, scroll to the bottom of this post for a link.
The custom workflow activity
The custom workflow activity has the following parameters:
- Queue - input - Reference to the queue that contains the case
- User - input - Reference to the user who will be assigned the case
- Assign - input - Flag for whether to assign the case or just return the case details
- Remove from queue - input - Flag for whether to completely remove the case from the queue when it is assigned
- Case id - output - Case GUID as a string (string because it makes working with non-existing cases easier in the custom action)
- Case number - output - Case ticket number value
- Case found - output - Flag for whether a case was found
- Case title - output - Case title value
The activity then executes a FetchXML query to retrieve unassigned cases in ascending order of the date they entered the queue. If the "assign" flag is set to true, the first case is assigned to the user, and then the details are returned as output parameters. If the flag is set to false, the case details are returned as output parameters, but the case is not updated.
The CRM action
The action is the simplest part of the solution. It just takes input parameters to pass to the custom activity and then returns the output parameters.
The web resource
The image below shows the output after the get next button is clicked:
You can download all the custom code and a CRM solution extract from my Crm-Sample-Code repository on GitHub. Happy case management!