Monday 4 December 2017

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

Sometimes we have to display some related values in a module from other modules in CRM, But may be we cannot directly put it through studio. In these cases we have to customize the edit & detail view of that module..
For eg: Consider You have agreeement Module, In that module suppose direcly u r linking a partcular customer record only, but if u want to show in the detail view of partcular agreement like, Customers address, Phone number, Contactable status.etc.., direcly this is not possible via studio So For this purpose we have to customize...

1) First You have to open the partcular Module, Here For eg: Agreement Module..
Then CRM/custom/modules/Agreement/

Check a folder named view is their.. If not Create it...

create a file called  view.detail.php

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


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

class AgreementViewDetail extends ViewDetail {


  function AgreementViewDetail(){
  parent::ViewDetail();
  }


  function display(){

global $db;
if(empty($this->bean->id)){
global $app_strings;
sugar_die($app_strings['ERROR_NO_RECORD']);
}

$recordid= $this->bean->id;

$sql1 ="Query Here";
$row1 =$db->query($sql1);
$res =$db->fetchByAssoc($row1);
        //For eg:
        $address=$res['address']



$this->ss->assign("Employee_Address", $address);


        $this->dv->process();
echo $this->dv->display();

}




}
  ?>


  Now open the folder CRM/custom/modules/metadata

  Open the file named  detailviewdefs.php..

  Look for the corresponding field u craeated from studio:-
  for eg:-

        'lbl_detailview_panel1' =>
      array (
        0 =>
        array (
          0 =>
          array (
            'name' => 'address_c',
            'studio' => 'visible',
            'label' => 'LBL_ADDRESS',
            'customCode' => '{$Employee_Address}',
          ),
        ),
      ),

      Look For the specific field, & include the value in array like this..  'customCode' => '{$Employee_Address}',


      Now do a Quick Repair & Rebuild, the chnages will be saved..

No comments:

Post a Comment