Wednesday, May 6, 2015

Running CRM Dialog from Custom Ribbon button


 1.      Add custom button on form
Say Run Dialog


     2. Now create command for custom button

     3. Add  Action to command

For the action add “Open Url Action”



3. For Url Command set your dialog URL
         To get dialog URL run dialog using “Start Dialog” button


Then select dialog you want to run on button click, once dialog started copy URL of dialog from address bar



 5. Your dialog url will be look like 

https://{CRM Server}:444/cs/dialog/rundialog.aspx?DialogId=%7b83D90936-EBEC-4CE5-8A58-A1530DE30680%7d&EntityName=new_test&ObjectId=%7b0FCB7F66-5FA6-E411-B1DF-0050568C6D7D%7d

It has Dialogid, Entityname and ObjectId
ObjectId is the record id on which this Dialog is running.

 6. If you use this URL as it is on button command then dialog will be run on same record again and again. 

      7.  To pass ObjectId / record id dynamically, need to pass one parameter to Url command, defined for custom button. This parameter should be like




    8. Now update your URL command address to

https://{CRM Server}:444/cs/dialog/rundialog.aspx?DialogId=%7b83D90936-EBEC-4CE5-8A58-A1530DE30680%7d&EntityName=new_test

Noticed that I removed &ObjectId=%7b0FCB7F66-5FA6-E411-B1DF-0050568C6D7D%7d, this objectId is passed by parameter, that’s why Parameter Name is important. 

    9.  Save and publish your customization.


   10.   Now dialog will be run for record you are in from button.



11 comments:

  1. I'm using CRM 2013 on-premise in a partner-hosted environment with ADFS. If I don't use the parameters (i.e., embed ObjectId in URL) the dialog starts. However, if I try to pass the ObjectId as a parameter, I get an error. It's as if the parameter is not being passed correctly. Thoughts?

    ReplyDelete
  2. I figured out the issue. I had set the flag for Pass Parameters to True. I changed it to and it works now.

    ReplyDelete
  3. This is great! However, the dialog opens up a new window with an address bar. Is there any way we can mimic what it usually looks like as a dialog window?

    ReplyDelete
    Replies
    1. Choose the Window Mode as 'Modal Dialog' and it should work!

      Delete
  4. The Dialog opens in new window, problem is if i import from dev to test environment i need to change every time the url. Is there any process i can change the org name by passing params

    ReplyDelete
    Replies
    1. First off, excellent post Mahadeo.

      By omitting the url and org as shown below this can work across different organizations/environments(servers).

      /cs/dialog/rundialog.aspx?DialogId=&EntityName=

      Delete
  5. i have a problem, not open the dialog...

    ReplyDelete
  6. Is there any way we can pass the dialog ID as a parameter rather than GUID ID

    ReplyDelete
  7. hi I have an issue with objectID - please respond here if you can: https://community.dynamics.com/crm/f/117/t/278673

    Thanks

    ReplyDelete
  8. THANK YOU FOR THE INFORMATION
    PLEASE VISIT US
    CRM Solutions



    ReplyDelete