AnsweredAssumed Answered

Sugar 7 : adding 2 subpanels from the same custom module but with different queries

Question asked by Gaelle Fernandez on Jul 30, 2014
Latest reply on Jan 12, 2015 by Gustav Lindström
Hi Sugarers,

i'm totally stuck in Sugar right now.
I have a custom module called cplus_ContactsPlus and standard Accounts module which are related with a M:M relationship.

So in Account record view, i can see one subpanel cplus_ContactsPlus.

First of all, i would like to override this subpanel query to display only cplus_ContactsPlus with nature = "Parrain" . How do i override the subpanel query in Sugar 7?

Secondly, i would like to add a second subpanel cplus_ContactsPlus on Accounts module, but this time the records will be displayed only if their nature ="Tremplin". How do i add another subpanel to Accounts Module?

I've already tried some things :

in custom/modules/Accounts/client/base/layouts/subpanels/subpanels.js, i've add these two subpanels definitions :

array (
      'layout' => 'subpanel',
      'context' => array (
          'link' => 'cplus_contactsplus_accounts_1',
array (      'layout' => 'subpanel',
      'context' => array (
          'link' => 'cplus_contactsplus_accounts_1',

In custom/Extension/modules/Accounts/Ext/Layoutdefs, i've the first subpanel created by the relationship, which is "cplus_contactsplus_accounts_1_Accounts.php" and i added cplus_contactsplus_accounts_2_Accounts.php, which is the copy of the first file, but with named replaced.

 this is the code of  cplus_contactsplus_accounts_1_Accounts.php:

<?php // created: 2014-07-22 11:53:33
$layout_defs["Accounts"]["subpanel_setup"]['cplus_contactsplus_accounts_1'] = array (
  'order' => 100,
  'module' => 'cplus_ContactsPlus',
  'subpanel_name' => 'default',
  'sort_order' => 'asc',
  'sort_by' => 'id',
  'get_subpanel_data' => 'cplus_contactsplus_accounts_1',
  'top_buttons' => 
  array (
    0 => 
    array (
      'widget_class' => 'SubPanelTopButtonQuickCreate',
    1 => 
    array (
      'widget_class' => 'SubPanelTopSelectButton',
      'mode' => 'MultiSelect',

Unfortunately, on Accounts module, there is only ONE subpanel showing for cplus_ContactsPlus, and it is the second one. i've tried to change order in subpanels.php and it showed me the default one made by relationship. So it is strange, but it appears that Sugar limits the number of subpanel from the same module.

So again,
 - How do i override the subpanel query in Sugar 7?
 - How do i add another subpanel from the same custom module to Accounts Module?

Thanks to help me with that, i'm really stuck... :/