Monday 4 December 2017

Customizing Values of Fields in List view of SugarCRM/SuiteCRM?


Sometimes we want to change the colour or show some value in the list view of Sugar/Suite CRM. This we cannot do like the customization od edit & detail view explained in the previous posts. Here we have to do something different...
Here we have to make changes in the Core File itself..
 For eg: Consider you have an agreement module, You want to change colour of one field in agreement module to green or red. Like If agreement status is approved then the field should go green if it is unapproved its colour should go red..

 For that Navigate to CRM/modules/Agreement/ Folder..

 In that open file called Agreement.php

 <?php

 require_once('modules/Agreement/Agreement_sugar.php');
class Agreement extends Agreement_sugar {

function __construct(){
parent::__construct();
}


function fill_in_additional_list_fields()
{
parent::fill_in_additional_list_fields();

if($this->status_c=="Approved")
{
$this->status_c='<span style="color:green">'.$this->status_c.'</span>';

}


if($this->status_c=="Unapproved")
{
$this->status_c='<span style="color:red">'.$this->status_c.'</span>';

}



}



}


?>



If You want to do some calculations dynamic also, we can do it Like:-
 <?php

 require_once('modules/Agreement/Agreement_sugar.php');
class Agreement extends Agreement_sugar {

function __construct(){
parent::__construct();
}


function fill_in_additional_list_fields()
{
parent::fill_in_additional_list_fields();


$amount=$this->amount_c;

//Want to calculate 10% of the amount dynamically and assign to another field called commission then

$percentageamount=$amount*(10/100);

//assign calculated value to our field

$this->commission_c=$percentageamount;

}



}


?>

After that Do a quick Repair & Rebuild & check it..

No comments:

Post a Comment