Launching a Dialog from a Ribbon Button in CRM 2011

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, 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 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

9 thoughts on “Launching a Dialog from a Ribbon Button in CRM 2011

  1. JJ

    Hi, looks very interesting.

    I did try to download and install your solution on RC1, but when I attempt to run it, I got error message:

    Record is Unavailable, The requested record was not found or you don not have sufficient permissions to view it.

    I did publish installed solution and I am admin/customizer. Any ideas?


    1. Gareth Tucker Post author

      Hi, check the Dialog Process included in the solution, it may need to be mapped to your environment. Failing that, I can send you an updated jscript file which provides a more precise REST query (I can’t do that just at the mo sorry).

      1. JJ

        Hi, no worries.

        dialog did not get published – I had to update it with proper currency (based on my settings). Then it gets activated. Separately dialog works fine, but button still does not work.

        I installed solution to default org.

      2. Gareth Tucker Post author

        Hi, I’ve uploaded a new version of the solution that has a more precise jquery. I’ve tested this on a fresh CRM online instance and it works for me. I tried on an on premise install and it is failing there. I made some adjustments to the jscript that builds the URLs used but am still hitting an issue on premise. I’m out of time I’m afraid, so for now, this is only going to work online.

    2. JJ

      I can’t comment on code as I don’t code, but I did check server log and when button is used, this exception is logged:

      Exception type: CrmException
      Exception message: Could not find a web resource with name new_HTMLWebResource.

      Which is odd as given file is within WEBResources in CRM and is published.
      Also, if I take URl from web resource itself, and run it in separate window, pop up comes up with ‘failure 1’. Not sure whether it’s related.


  2. Dominic

    Hi Gareth

    Could you tell me if it is possible to display the results of the name search in a grid view instead of a drop down? If you are searching on names, across an entire system, returning just the name obviously present issues around duplicate names. It would be ideal if a grid view was showbn with post code, d.o.b etc to help id & v.


    1. Gareth Tucker Post author

      Hi, no the pick list display is the only display option available. From memory you can have multiple columns returned – e.g. Name, Customer #, Phone Nbr – but the fields are just strung together in the pick list. Perhaps dialogs are not the right choice for you in this instance.

  3. Robert Ezekiel


    This is FANTASTIC. This example and your previous article on CRM 2011 Dialogs has been most helpful in accelerating my learning on how to use them.

    Thanks so much.


  4. Eric


    This is awesome and i have done something similar but if my contact query doesn’t pull back any results it will not allow the user to select the next button. It must have a record to display in the drop down list before allowing them to move forward. Any suggestions?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s