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.