Menu
SuiteCRM dedicated support 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 4 days 12 hours ago #75325

  • mrlee
  • mrlee's Avatar
  • Offline
  • New Member
  • 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
<?php
$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)
<?php

require_once('include/MVC/View/views/view.list.php');

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

class CompaniesViewList extends ViewList
{

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

public function display(){
$short_description = substr($this->bean->description,0,100);
$this->ss->assign("short_description","$short_description");
parent::display();
}

}
?>
..in 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/
'SHORT_DESCRIPTION' =>
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 4 days 5 hours ago #75337

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8557
  • Thank you received: 1307
  • Karma: 311
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:

docs.suitecrm.com/developer/extension-framework/

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

pgorod.github.io/Audit-File-Accesses/

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.074 seconds
Powered by Kunena Forum