HOWTO: Displaying Meetings related to Contact in Account’s subpanels.

sugarcrmdevelopers —  March 11, 2011 — 4 Comments

Editor’s Note: This post comes directly from this forums post, where poster erop gave a very detailed guide on how to display meetings related to an Account’s Contacts in the Activities subpanel. You could apply this same technique for the Calls module as well, or to any other custom module as well. Thanks erop for providing such great information for all Sugar developers to learn from.

We can explore code in modules/Accounts/metadata/subpaneldefs.php to find out how to add such an item. What is more important is how to get the data for this new collection item. After digging through forum posts (especially posted by andopes) I realized that ‘get_subpanel_data’ attribute is responsible for that. And it can be defined in two ways: explicitly define a database table name as a data source or use custom SQL query. This custom SQL query should be defined in a focused bean class and referred with ‘get_subpanel_data’ => ‘function:my_custom_method_in_extended_bean_class’ construction. There are two more (still blackbox-ed for me) attributes needed to define function:

So my working custom layout definition in custom/Extension/modules/Accounts/Ext/Layout/custom_meetings_subpanel.php looks like:

After that we should extend default Account class to implement custom method (in my case ) get_all_meetings_related(). To make this modification upgrade-safe we can create custom/modules/Accounts/AccountsDetailView.php which extends default Account class:

The “magic” is in $return_array array that is an SQL query for selecting “meetings-related-through-contacts” split into several pieces and spread into appropriate $return_array keys.

At first when I built and test a query into MySQL Workbench I use UNION operator to get all related Meeting IDs. But then I realized that this job is done with ‘type’ => ‘collection’ attribute of $layout_defs.

The last step is to let our extended bean class loaded in DetailView. For that we create or modify custom/modules/Accounts/controller.php:

So here is my working code.

Hope I didn’t miss something important. I will appreciate if pro Sugar developers fix my mistakes in the post if any.

4 responses to HOWTO: Displaying Meetings related to Contact in Account’s subpanels.


    require_once ‘custom/modules/Accounts/AccountDetailView.php’; should be changed to require_once ‘custom/modules/Accounts/AccountsDetailView.php’;


    Thanks for catching that, updated now.


    How can i do this with SUgar 6.4.5?

    rohan sharma May 9, 2013 at 7:41 am

    hello john ,
    i have query , i have got stuck with subpanels , i HAVE A MODULE accounts that contains subpanels like opportunities ,targets ,leads. Now i want display total of a particular field say amount under opportunities sub panel .
    Where i can write the code to get the sum under subpanel opportunities.

Leave a Reply

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

You are commenting using your 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