Controlling the properties of New Buttons adding using the Client Side API

The previous article "Calling Extensions (ASP pages and .NET assemblies) from Buttons added using the Client Side API" discussed how new buttons can be added to system screens.

This article will look at how we can add the button exactly where we need and how we can control the behaviour of the button.

You can read about the addButton method in the online documentation.

http://help.sagecrm.com/js-api/classes/crm.html#method_addButton

The basic usage of the method is

crm.addButton (buttonURL, captionfamily, captioncode, [options object] )

The fourth parameter is either a string (as in the example below) or an object that defines the properties to be used in the button definition.

[code language="javascript"]

[/code]

Note: The code above can be added to the Custom Content box of the CompanyBoxLong screen.

The simple 'string' example above adds the button onto the screen but at the end of the existing panels of button below the 'Help' button. This would normally not be a very desirable thing as the bottom button on the right of the page should be the Help button to ensure a consistent user experience.

Building the Object

Consider this code

[code language="script"]

[/code]

The options are passed as an object in JSON with the following parameters

{
'href': '#',
//The hyperlink location
'index': 2,
//This represents the position in the Button group.
click:function(){window.open(stringURL, 'newwindow' , 'toolbar=0 , scrollbars=0, location=0, statusbar=0, menubar=0 , resizable=0, width=800, height=400, left = 340, top = 200');
//The function called
}

Anonymous