Shane Dowling : SugarCRM 7 — Adding a custom column to a list

This is the SugarCRM 7 equivalent to this post here, because Sugar has dropped the process record logic hook, we need to come up with a new solution.

Here's how you can add a new column to a list view, I have to admit this is one of the really powerful additions to SugarCRM 7, no more crazy config files or hacks to try cheat your data in. By leveraging javascript events with a decent restful API you can come up with some really nice solutions, with lots of hooks to do custom things. Once you see the difference in implementation you'll see why I'm so pleased.

So anyway, back to the customisations.

1. Add the placeholder column

You need to do this by adding a new column into your custom modules list.php file, which is generally located at custom/modules/YOUR_CUSTOM_MODULE/clients/base/views/list/list.php, add your new column in under


array (
 'name' => 'custom_fieldname',
 'label' => 'LBL_CUSTOM_RECORD',
 'enabled' => true,
 'width' => '10%',
 'default' => true,

### 2. Add the JS action

This should go into

this.before('render', function() {
 return this.beforeRenderCallback()
 }, this);
 this.on('render', function() {
 if (this.previewVisible) {
 }, this);
 * Callback for before on('render') event
 this.collection.each(function(model) {'GET', app.api.buildURL('YOUR_CUSTOM_MODULE/YOUR_CUSTOM_FUNCTION/', null, {
 your_custom_field : data
 }, this)
 }, this);

### 3. Add the API end point

The documentation here is really straightforward but as an example for
completeness this should return a json response with the data needed.

This code would go into

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class YOUR_CUSTOM_FUNCTION extends SugarApi
 public function registerApiRest()
 return array(
 'MyGetEndpoint' => array(
 //request type
 'reqType' => 'GET',

//endpoint path
 'path' => array('YOUR_CUSTOM_MODULE', 'YOUR_CUSTOM_FUNCTION', '?'),

//endpoint variables
 'pathVars' => array('', '', 'data'),

//method to call
 'method' => 'MyGetMethod',

//short help string to be displayed in the help documentation
 'shortHelp' => 'Some help text',

//long help to be displayed in the help documentation
 //'longHelp' => '',

 * Method to be used for my MyEndpoint/GetExample endpoint
 public function MyGetMethod($api, $args)
 $id = $args;

$custom_bean = new Custom_Bean();

return $custom_bean->getCustomColumnData();


4. Add to column to the dictionary


$dictionary['YOUR_CUSTOM_MODULE']['fields']['custom_fieldname']['labelValue']='Custom Row ';
 $dictionary['YOUR_CUSTOM_MODULE']['fields']['custom_fieldname']['full_text_search']=array (
 'boost' => '0',
 'enabled' => false,

On quick repair/rebuild this will get merged into custom/modules/YOUR_CUSTOM_MODULES/Ext/Vardefs/vardefs.ext.php

5. No need to even guess, do a quick repair/rebuild.