You can add a button 

  • In a custom ASP page
  • In a the code of a .NET assembly
  • In a an existing system screen

Buttons in an ASP Page

If this is in an ASP page then the code for a simple button to call an external ASP page looks like


var strCallASPButton = CRM.Button("ASP","save.gif", CRM.Url("http://myserver/myPage.asp"));
myBlock.AddButton(strCallASPButton);
 

A full discussion of buttons in ASP pages can be found in the article "Adding Buttons to an ASP Page".

Buttons in a .NET assembly

If this is in the code for a .NET assembly then the code for a simple button to call an external ASP/ASPX page looks like


AddUrlButton("CaptionCode", "Image.gif", Url("http://myserver/myPage.asp"));
 

Members of the Developer Program have access to the .NET SDK and documentation which have extensive examples and snippets that show the creation of Custom Buttons.

Buttons in a System Page

If you just want to add a button to a system screen using the Button Groups feature, then you need to use the 'customurl' action and the URL name will be a PsuedoURL like this:


javascript:x=window.open('http://community.sagecrm.com?crm=true'+GetKeys(),'new');void(x);

For another example of a PseudoURL see the article "Adding a Print Button to a System Screen".  

Note:  void is a javascript operator that is used to return a null value so the browser will not load a new page.  We want to stay on the existing system page on popup the new page. The void operator requires a value and cannot be used by itself. 

The code above will pop up the external site in a new browser window and pass to it the current context information.  This trick uses the GetKeys() system function which is discussed in the article "Grabbing Key Values client side".

Note:  The field 'URL name' only has a limited amount of space so you may have to add the code as a function in the screens custom content box and then call the function from the pseudo URL

You can see an example of this combination of PsuedoURL and function defined in a custom content box in the article "Adding a Report Button to an Existing System Screen, e.g. OpportunitiesList".