display contact data in custom list view

I created a new module that has a many-to-one relationship with Contact.  This module is intended to record the office visits for a contact.
In the Office Visit list view, I would like to display additional fields from the contact for example, birthdate.  The list view is already displaying the concatenated contact name along with fields from the Office Visit table but I cannot figure out how to add additional contact fields. 

I am using SugarCRM 6.5.24 (CE)

My module is called HBF01_Initial_Exam

I added birthdate to custom/extension/modules/HBF01_Initial_Exam/Ext/Vardefs/hbf01_initial_exam_contacts_1_HBF01_Initial_Exam.php

<?php
// created: 2017-02-28 16:02:29
$dictionary["HBF01_Initial_Exam"]["fields"]["hbf01_initial_exam_contacts_1"] = array (
  'name' => 'hbf01_initial_exam_contacts_1',
  'type' => 'link',
  'relationship' => 'hbf01_initial_exam_contacts_1',
  'source' => 'non-db',
  'module' => 'Contacts',
  'bean_name' => 'Contact',
  'vname' => 'LBL_HBF01_INITIAL_EXAM_CONTACTS_1_FROM_CONTACTS_TITLE',
  'id_name' => 'hbf01_initial_exam_contacts_1contacts_ida',
);
$dictionary["HBF01_Initial_Exam"]["fields"]["hbf01_initial_exam_contacts_name"] = array (
  'name' => 'hbf01_initial_exam_contacts_name',
  'type' => 'relate',
  'source' => 'non-db',
  'vname' => 'LBL_HBF01_INITIAL_EXAM_CONTACTS_1_FROM_CONTACTS_TITLE',
  'save' => true,
  'id_name' => 'hbf01_initial_exam_contacts_1contacts_ida',
  'link' => 'hbf01_initial_exam_contacts_1',
  'table' => 'contacts',
  'module' => 'Contacts',
  'rname' => 'name',
  'db_concat_fields' =>
  array (
    0 => 'first_name',
    1 => 'last_name'
  ),
);
$dictionary["HBF01_Initial_Exam"]["fields"]["birthdate"] = array (
  'name' => 'birthdate',
  'type' => 'date',
  'source' => 'non-db',
);
$dictionary["HBF01_Initial_Exam"]["fields"]["hbf01_initial_exam_contacts_1contacts_ida"] = array (
  'name' => 'hbf01_initial_exam_contacts_1contacts_ida',
  'type' => 'link',
  'relationship' => 'hbf01_initial_exam_contacts_1',
  'source' => 'non-db',
  'reportable' => false,
  'side' => 'right',
  'vname' => 'LBL_HBF01_INITIAL_EXAM_CONTACTS_1_FROM_INITIAL_EXAM_TITLE',
);

I also tried adding birthdate to htdocs/modules/HBF01_Initial_EXAM/vardefs.php.  The label is added to the list view but the data is always empty.

This is what I see in the SugarCRM.log

07/08/17 18:39:55 [5188][1][DEBUG] SugarBean[HBF01_Initial_Exam].load_relationships, Loading relationship (hbf01_initial_exam_contacts_1).
07/08/17 18:39:55 [5188][1][DEBUG] Limit Query: SELECT  hbf01_initial_exam.id ,hbf01_initial_exam_cstm.appt_ttime_c,hbf01_initial_exam_cstm.arrival_time_c,
hbf01_initial_exam_cstm.clinic_loc_c , LTRIM(RTRIM(CONCAT(IFNULL(jt0.first_name,''),' ',IFNULL(jt0.last_name,'')))) hbf01_initial_exam_contacts_name, jtl0.hbf01_initial_exam_contacts_1contacts_ida hbf01_initial_exam_contacts_1contacts_ida, hbf01_initial_exam.status , hbf01_initial_exam.assigned_user_id  FROM hbf01_initial_exam  LEFT JOIN hbf01_initial_exam_cstm ON hbf01_initial_exam.id = hbf01_initial_exam_cstm.id_c   LEFT JOIN  hbf01_initial_exam_contacts_1_c jtl0 ON hbf01_initial_exam.id=jtl0.hbf01_initial_exam_contacts_1hbf01_initial_exam_idb AND jtl0.deleted=0
 LEFT JOIN  contacts jt0 ON jt0.id=jtl0.hbf01_initial_exam_contacts_1contacts_ida AND jt0.deleted=0
 AND jt0.deleted=0 where hbf01_initial_exam.deleted=0 ORDER BY birthdate ASC Start: 0 count: 21

Your help is greatly appreciated.

Parents Reply Children
  • The logic_hook process_record method may looks like that:

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

     

    class logic_hooks_class

    {

        function process_record_method($bean, $event, $arguments)

        {

            $contact = BeanFactory::getBean('Contacts', $bean->hbf01_initial_exam_contacts_1contacts_ida);

            $bean->birthdate = $contact->birthdate;

        }

    }

    Now you only need to defined the extended logic hook.

    Kind regards

    André Lopes
    Lampada Global
    Skype: andre.lampada