SuiteCRM Pull Request Party hosted by SalesAgility
Welcome, Guest
Username: Password: Remember me

TOPIC: Create new column in list view as a derivative from existing field

Create new column in list view as a derivative from existing field 5 months 2 weeks ago #75325

  • mrlee
  • mrlee's Avatar
  • Offline
  • Banned
  • Posts: 1
  • Karma: 0
I am new to SuiteCRM - as well as to the forum - and currently trying to set up a list view for companies. these companies have "descriptions". however, I want to shorten the description at about 100-150 chars max in the list view.

On the one hand,I was able to directly reference the description fields via a logic hook solution in such a way that each individual entry was limited at 100 chars (substr).
On the other hand, what if I simply want to create a column that receives the same input from the description field and shortens the amount of characters itself. Let's just assume I want to give an admin the choice to decide between showing the entire description or showing at most 100 chars of the description.

Is there a standard routine that allows me to create new fields or columns in SuiteCRM by creating custom views and manipulating viewdefs? maybe I immediately ran into the most complex problem in case of listviews which led me to being forced to use logic hooks for that but isnt there another way to just go a simpler way?

So far, I have created a short_description.php in custom/modules/Ext/Vardefs
$GLOBALS["log"]->FATAL("lets see if i can manipulate fields...");
$dictionary["Companies"]["fields"]["short_description"] = array(
'name' => 'short_description',
'vname' => 'short_description',
'type' => 'varchar',
'len' => '255',
'source' => 'non-db',
However, the logger wont go off. it seems like the code never gets reached.

I created a view.list.php in custom/modules/Companies/views (in which I was desperately trying to achieve anything)


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

class CompaniesViewList extends ViewList

public function preDisplay(){
echo "There is indeed a short_description variable";
echo "There is no short_description variable<br>";
echo 'I can access description';
$short_description = substr($this->bean->description,0,100);
else {
echo 'I cannot access description<br>';

public function display(){
$short_description = substr($this->bean->description,0,100);

?> which the description field of the bean seems to be empty all the time although the description field does indeed show me results

and I added a "short_description" entry in listviewdefs.php in custom/modules/Companies/metadata/
array (
'width' => '10%',
'label' => 'short_description',
'default' => true,
'customCode' => '{$short_description}',

At this moment, there is a short_decription column displayed. However the cells are entirely empty and nothing gets to be shown. Any idea?

The administrator has disabled public write access.

Create new column in list view as a derivative from existing field 5 months 2 weeks ago #75337

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 9885
  • Thank you received: 1474
  • Karma: 350
Sorry, I don't have time to go into your question in detail, but here is a tip to get you started: you're not supposed to create files in custom/modules/Ext/Vardefs, you should be doing that under custom/Extension. Then the QR&R would compile all extensions together in a file under custom/modules/Ext/Vardefs.

Check this chapter:

Finally, when you're lost trying to figure out customization file locations, this can be a great help:

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.
Time to create page: 0.041 seconds
Powered by Kunena Forum