Here’s some sample code that demonstrates how to execute a Dialog from a Ribbon button in CRM 2011. The solution sample is provided in managed and unmanaged formats:
Managed Solution (updated: 25 Feb 2011)
Unmanaged Solution (updated: 25 Feb 2011)
note: this has only been tested successfully in CRM Online
I have built out a Dialog based solution for a call centre, further extending the solution I documented in one of my earlier blogs. The scenario is as follows:
A call centre agent takes both sales and service inbound calls. They are tasked with:
- searching for the caller in CRM and adding them as a new Contact if not found
- determining whether the call is sales or service related
- logging the phone call in CRM
- recording a new opportunity or case
- informing the caller they will be called back within 24 hours
I wanted a Dialog based solution that would guide the call centre agent through the process with the minimal number of clicks. I didn’t want the user to have to create the initial CRM record required for the Dialog, I wanted the user to simply click a button. My solution design makes use of the REST End Point to retrieve the GUID of the Dialog that should be launched and also to create the initial Phone Call record. Dialog’s are URL addressable so launching the dialog is not difficult once you have the context record and the Dialog GUID. In the Dialog itself I make use of Dialog Variables and Database Queries to query CRM to see if the Caller exists and to present a list of possible matches back to the user. Pretty powerful stuff.
The end result looks like this…
The user has an incoming call, they click the Incoming Call button.
The Button executes a jscript function that does a window.open, launching an HTML page I’ve loaded into CRM as a web resource.
An HTML page pops indicating a Phone Call is being created and the Call Script is being loaded:
This HTML page is used to reference some jscript libraries I need to extract the CRM context and for the execution of the REST call. The HTML page provides the progress indicators to the user and then executes a jscript function that does the heavy lifting.
The jscript function:
- queries the REST end point for Processes to retrieve the GUID of the “Inbound Call Script” Dialog Process.
- uses the REST end point for Phone Calls to create a Phone Call record.
- formulates a URL using the CRM context, Dialog GUID and the Phone Call GUID
- does a window.open to launch that URL
And then the Dialog appears:
The Call Centre Agent greets the caller, notes there reason for calling and collects their name (as prompted by the Dialog script):
The script then prompts the agent to find out whether the caller has an existing account:
If the caller indicates they are an existing customer a Contact search page is presented:
A search is executed against CRM using the search strings entered (doing a “like” search). And the search results are returned to the agent for review:
The user can go back and modify their search, or they can select one of the search results, or they can indicate the caller was not found in the database:
Finally, the agent selects the nature of the enquiry so that an Opportunity or Case record can be created in CRM:
The final page of the Dialog provides the call wrap up script:
Behind the scenes a Phone Call record has been created and linked to either an existing Contact or to a new Contact. A Case or an Opportunity has been created and linked to the Contact. And the Phone Call has been marked as completed.
I was pretty impressed by the extensibility offered by the CRM platform here. The REST end point performed a little slowly for me but I haven’t tried to performance tune anything here. The Dialog functionality largely bent the way I needed it to. The area it was weakest was the display of the Query Results, where a pick list is not really suitable.
To see this in action:
– Download the solution, install, publish and refresh your browser
(Known Issue: Check the Dialog is Active. The Dialog definition contains references to the Australian currency which prevent it from publishing in instances missing that currency. Edit those mappings as required)
– Navigate to Workplace –> Contacts
– The “Incoming Call” button should appear on the Ribbon (it appears on the “Main” tab for the core data entities, i.e. on the Account and Contact ribbons)
– Click the button
– Navigate the dialog
– At conclusion you should see:
– A new completed Phone Call record
– Attached to either a new Case or a new Opportunity
– And both records related to either an existing Contact or a new Contact