HOWTO: Add a field from a related module into the ListView

bsoremsugar —  April 26, 2011 — 12 Comments

Here’s a question from the forums I saw recently:

I need to show Contacts Phone work number in Call list view.
Can anyone help me how to do it?

This commonly comes up, and while there is a way to do this it isn’t upgrade-safe since we need to edit a bean method to do so. However it still is possible by doing two small edits. First, we need to modify the Call bean’s get_list_view_data() method to grab the phone number from the related contact as shown below.

Now, we just need to add the field to the list of fields we will show for the Calls listview in the modules/Calls/metadata/listviewdefs.php as shown below:

With a refresh, the field will now show up in the listview. Notice above that we’ve marked the field as not sortable, since it would be impossible to sort the field since it’s added on after the query is run.

12 responses to HOWTO: Add a field from a related module into the ListView

  1. 

    I am trying this method, but there is no data showing for my column in the listview.  Is there anything that has to be done in vardefs.php for this method to work?
     

  2. 

    I am trying to modify my activities, calls, listview to match what is on home, mycalls – specifically whether the call is for a contact or lead.  It does on home, mycalls but not on calls list overiew in activites.

  3. 

    Method works, thanks! but, there an little error : get_list_view_data() must looks like that:

    function get_list_view_data(){
       $sv=$this->get_list_view_array();
       // Grab the contact phone number   if ( !empty($this->contact_id) ) {   $contactFocus = new Contact;   $contactFocus->retrieve($this->contact_id);   if ( !empty($contactFocus->id) ) {       $sv['CONTACT_PHONE_WORK'] = $contactFocus->phone_work;   }   }  return $sv; }

  4. 

    How can I add a fields from related Module to EditView, modules related in one-to-many

Trackbacks and Pingbacks:

  1. adding condition to ListViewGeneric.tpl - SugarCRM Forums - September 8, 2011

    [...] [...]

  2. Get Module Name In ListView Customcode - August 15, 2012

    [...] [...]

  3. Combine ListView of two different module in other module's ListView - October 15, 2012

    [...] [...]

  4. Adding Related Fields to ListView - February 27, 2013

    [...] [...]

  5. Next Scheduled Call in Lead List View - May 2, 2013

    [...] [...]

  6. Add a select action in a listview action - June 28, 2013

    [...] [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s