How to Create subpanel using relate field

Hello,

I have Sugar 6.* version.

I have created one custom module, relate field with contacts module.

Now I need to display subpanel at Contact detail page.

Parents Reply Children
  • I would think that for a 1:1 you get a relate field on each side of the relationship so you wouldn't need a subpanel.

    Should you still want a subpanel, since the relationship exists, regardless of cardinality, you can add a subpanel by adding it explicitly to the vardefs.

    For example, I wanted a subpanel for TargetLists (aka ProspectLists) on the Targets (aka Prospects) module.

    <mysugar>/custom/Extension/modules/Prospects/Ext/clients/base/layouts/subpanels/prospectlists.php

    <?php
    $viewdefs['Prospects']['base']['layout']['subpanels']['components'][] = array (
      'layout' => 'subpanel',
      'label' => 'LBL_PROSPECTLISTS_TITLE',
      'context' =>
      array (
        'link' => 'prospect_lists',
      ),
    );

    Note that the link is the name of the relationship on the Prospects side. I found that in the vardef.php file of the Prospects module (it is important to note that the name, in this case prospect_lists' is not the same as the relationship prospect_list_prospects which is what you see in Studio)

            'prospect_lists' => array(
                'name' => 'prospect_lists',
                'type' => 'link',
                'relationship' => 'prospect_list_prospects',
                'module' => 'ProspectLists',
                'source' => 'non-db',
                'vname' => 'LBL_PROSPECT_LIST',
            ),

    The label goes in 

    <mysugar>/custom/Extension/modules/Prospects/Ext/Language

     

    Because the relationship is 1:1 you may want to prevent people from linking existing records through the subpanel, or adding new ones. For that you need to customize your panel-top. See:

    SugarCRM7 HOW TO:  Manipulate Subpanel Top Buttons (Actions) 

     

    Hope this helps,

    FrancescaS