CRM Blog

Adding A Button To CRM

by Danny Varghese 03.16.08

In CRM, it’s widely known that you can add buttons to both system and custom forms.  However, there aren’t too many examples on how to do it, and also some practical examples.  To add a button to a CRM form, you simply need to edit the ISV.config.xml file and then reset IIS. 

Here’s an example on how to add a button on the Account form that when clicked, will open a new internet explorer page to www.microsoft.com.

1.        Go to the following directory where the ISV.config.xml is located: C:\Program Files\Microsoft CRM\CRMWeb\_Resources and back up the file.

2.       Open the file using any xml/text editor (NOTE: Some text editors may cause the xml to get corrupted so be careful.  Ideally an XML editor is recommended).  Add an entry for a new button to the Account toolbar.

a.       <Button ToolTip = “Open Window” Icon =”/<insert relative path>” Title = “Open Window” JavaScript=”window.open(‘http://www.microsoft.com’)”;/>

<ToolBarSpacer/>

3.       In the above example you can see I navigated to the Account entity’s toolbar and created the entry with the following parameters:

a.       ValidForCreate: 0 = button will not show up on a “Create” form. 1 = button will show up on a “Create” form.

b.      ValidForUpdate: 0 = button will not show up on an “Update” form.  1 = button will show up on an “Update” form.

c.       Button ToolTip:  when a user performs a mouse over action on the button, a dialog box will appear with whatever text specified here.

d.      Icon: relative path of the icon used for the button. 

e.      Title: name to appear on the button.

f.        BLOCKED SCRIPT whether to attach a JavaScript code snippet or function to the click on the button.  (NOTE: You can also reference a JavaScript method here that exists in another file, however, that file must be referenced at the onLoad() or onSave() methods of that form)

4.       A new button should now appear on the toolbar and after clicking it, a new internet explorer page opens to www.microsoft.com

Some really neat applications I’ve seen are below:

1.        Add a button on the Account/Contact form that takes the address, sends in the parameters to MapQuest or Google Maps, and pops a window with a map of the location.

2.       Add a button on any form, that when a user clicks, will create an identical copy of that form (Clone function).  This can be useful when entering data numerous times where only a few entries may be different.

3.       Add a button that is a shortcut to the “Apply Rule” menu item in the Action menu.

Comments

# Ron Wilson said on March 18, 2008 10:25 PM:

What about the different actions that can be performed on certain system entities?  For exampe, in the Case entity, there is a Resolve Case option that goes to the Case Resolution entity.  How could this be implemented on a custom entity?

# Danny Varghese said on May 22, 2008 02:45 PM:

Hi Ron,

I'm terribly sorry for not responding sooner!  I've been away for the past two months and am just getting back.  Are you asking how to perform these with a simple button push?

If so, all you do is the javascript that you've referenced in the button configuration, you can do the following:

1.  Create a .Net web project that performs all the actions you require.

2.  You'll now have a front end .aspx page, and the "code behind" will contain all the development. You have the option to return results/values from the execution of code, but it has to be in xml format.

3.  In your JavaScript file, build a URL which contains your CRM site url and append to it a location relative to the install directory containing the front end .aspx file mentioned in (2)

4.  Create a new ActiveX object and call the .load() method which will call the aspx page and send in the url you've created.  NOTE: you can append to the url parameters the code may need.

The JavaScript may look something like this:

//build the url to call the .aspx page

var url = getSiteAddress()+ "/_crowe/crowe_x_test.aspx?";

//get parameter to pass into the url

var testId = crmForm.all.new_testid.DataValue;

//create the ActiveX object

var activeXObject = new ActiveXObject("Msxml2.DOMDocument");

activeXObject .async=false;

//add the parameter to the url

var testUrl =  url + "testId=" + testId;

activeXObject.load(testUrl);

for (var i = 0; i < activeXObject.childNodes.length; i++)

{

var result = activeXObject.childNodes[i].text;

}

The .aspx page (as mentioned above) is in a relative path as seen in the construction of the url above.  That page references an assembly file of the project you should've created in Step (1).  That file should be placed in the following directory in order for it to work properly:  CRM Install Directory\CRMWeb\bin

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Security Check
Please answer the simple math problem below.

(required)