SugarCRM Customization: A Step-by-Step Guide to Create A Custom Field in The Relationship Table

Add custom field in the subpanel from relationship table

This blog is intended for SugarCRM developers aiming to create a custom field in the subpanel from the relationship table. Let’s explore the significance of customization in SugarCRM. When certain requirements cannot be met through personalization or configuration within Sugar, code-level customization becomes essential. Such customizations may involve expanding the out-of-the-box functionality by extending the SugarCRM code or integrating SugarCRM with third-party applications using RestFul API services. The people who are new to SugarCRM first they should go through the end user guide, admin guide and then only they can learn the SugarCRM custom development because it requires some understanding about how the application works and what and all the default features are available and how the SugarCRM can be personalized and configured by using Sugar default developer tools.

Now let us understand what is the importance of this blog. We all know that we have the Many to Many relationship from Opportunities to Contacts by default in Sugar. So one Contact can have multiple Opportunities and similarly one Opportunity can be associated with multiple contacts. So let us see an example how the role field in the subpanel plays a vital role here.

We all know that we have the Many to Many relationship from Opportunities to Contacts by default in Sugar. So one Contact can have multiple Opportunities and similarly, one Opportunity can have multiple contacts.
So let us see an example how the role field in the subpanel plays a vital role here.

How does the Contacts Role Field under Opportunities play a significant role in SugarCRM?

In SugarCRM, each Opportunity can be related to one or more contacts that are displayed in the subpanel on the Opportunities record view. The Contacts subpanel allows users to select an opportunity-specific role (e.g. Primary Decision Maker, Business Evaluator, etc.). Based on the role of the contact, will help us to decide how the individual contact will be the factor into the buying decision for the current Opportunity.

SugarCRM Contacts Role in Opportunity Subpanel

The same contact can be linked to multiple Opportunities and can have different roles for each specific opportunity. In this case we cannot create the field in the studio in the Contact. This role field should be only for Opportunity Subpanel.

Let us take an example how it works in real time. For instance, Person A might be the Technical Evaluator for Project ABC and the Primary Decision Maker for Project XYZ. This shows how one person handles different jobs in various projects. The role field custom development allows us to record and distinguish these varied roles across different projects. By using this field, we can easily identify and manage the diverse roles a person plays in various projects.

Creating Custom Subpanel Fields Through Customization for Many-to-Many Relationships in SugarCRM

This blog will guide you through creating a custom dropdown field in the Members subpanel under the Meetings Module. Imagine a scenario where there’s a Many-to-Many relationship between Meetings and Members – meaning multiple members can attend various meetings, and each meeting can have multiple attendees.

The ‘role’ field here serves as a useful indicator to mark whether a member attended a specific meeting or not. When we establish a Many-to-Many relationship between these modules, SugarCRM automatically generates metadata and relationship files in both modules’ vardefs.

However, since this field is part of a relationship, you can’t create it using tools like Studio or Module Builder. This has to be done through custom code development only. Adding small code snippets into specific files will help achieve this customization as mentioned in the below steps.

Adding the field in the Subpanel Module

To display the field in the subpanel, we need to add it to the metadata file. Follow these steps:

  • Navigate to the file path: (./custom/metadata/meetings_psme_members_1MetaData.php).
  • Inside this file, find the ‘fields’ array.
  • Add the following code snippet within the ‘fields’ array.
Note: The path mentioned (./custom/metadata/{link_name}MetaData.php) might differ based on the relationship. Typically, it will follow a similar structure, adjusting the ‘link_name’ based on the relationship between modules.

Adding the Field in the Relationship File

When establishing a Many-to-Many (M-M) relationship between modules like Meetings and Members, SugarCRM creates specific files in both module directories under Vardefs.

  • To incorporate the ‘meeting_status’ field into this relationship, follow these steps:
  • Locate the file at the path ./custom/Extension/modules/PSME_Members/Ext/Vardefs/meetings_psme_members_1_PSME_Members.php
  • Add the provided code snippet to the end of the file:
  • In this code, the ‘type’ parameter set as ‘enum’ indicates that ‘meeting_status’ will be a dropdown field. The ‘options’ attribute, set to ‘meeting_status_type_list’, specifies the list of options that will be available in this dropdown.
  • This addition within the relationship file defines the ‘meeting_status’ field as a dropdown, providing a predefined set of choices within the relationship between Meetings and Members.

Creating the Dropdown Field ‘Meeting Status’ in the Members Module

  • To display the status of a member for a meeting, create a dropdown field named ‘Meeting Status’ in the Members module. Follow these steps.
  • Create a file at the path: ./custom/Extension/modules//Ext/Vardefs/
  • Insert the following code into the new file created and save the file.
$dictionary['PSME_Members']['fields']['meeting_status']['name'] = 'meeting_status';
$dictionary['PSME_Members']['fields']['meeting_status']['type'] = 'enum';
$dictionary['PSME_Members']['fields']['meeting_status']['vname'] = 'LBL_MEETING_STATUS';
$dictionary['PSME_Members']['fields']['meeting_status']['importable'] = false;
$dictionary['PSME_Members']['fields']['meeting_status']['source'] = 'non-db';
$dictionary['PSME_Members']['fields']['meeting_status']['link'] = 'meetings_psme_members_1';
$dictionary['PSME_Members']['fields']['meeting_status']['rname_link'] = 'meeting_status';
$dictionary['PSME_Members']['fields']['meeting_status']['options'] = 'meeting_status_type_list';
  • Explanation of Parameters used in the above code are as follows.
  • ‘type’ => ‘enum’ → Specifies the data type of the field as a dropdown (‘enum’).
  • ‘link’ => ‘meetings_psme_members_1’ → Refers to the link name created during the relationship setup between modules.
  • ‘options’ => ‘meeting_status_type_list’ → Indicates the name of the dropdown list containing options for the ‘meeting_status’ field.
  • ‘PSME_Members’ module refers to the module name where this field is being added.
  • This code addition creates a dropdown field named ‘Meeting Status’ within the Members module, enabling the display and selection of different meeting statuses for each member.

Creating the Dropdown List ‘meeting_status_type_list’

  • To create the dropdown list ‘meeting_status_type_list’ used for the ‘Meeting Status’ field, follow these steps.
  • Navigate to the file path: ./custom/Extension/application/Ext/Language/.php.
  • Add the following code snippet into the file.
$app_list_strings['meeting_status_type_list'] = array(
  'Selected' => 'Selected',
  'Invited' => 'Invited',
  'Accepted' => 'Accepted',
  'Rejected' => 'Rejected',
  'Attended' => 'Attended',
  'Absent' => 'Absent',
  • This snippet of code defines the dropdown list ‘meeting_status_type_list’. Each key-value pair represents an option in the dropdow: ‘Selected’, ‘Invited’, ‘Accepted’, ‘Rejected’, ‘Attended’, ‘Absent’ are the options available for the ‘Meeting Status’ dropdown field.
  • By adding this code snippet to the specified language file, you create a list of selectable options for the ‘Meeting Status’ dropdown field in the Members module.

 Finalizing Changes and Updating Layout

  • Perform Quick Repair and Rebuild.
  • After placing all the necessary files, access the Admin section within your Sugar instance.
  • Perform the Quick Repair and Rebuild action. Execute the query generated after the repair process concludes. This ensures that Sugar recognizes and applies the recent changes effectively.
  • Adjust Layout via Studio by following the below steps.
  • Go to Studio and open the Meetings Module.
  • Navigate to Subpanels and locate the Members module.
  • In the ‘hidden layout’ section, find the newly created field.
  • Simply drag and drop this field from the hidden section to the ‘default layout’.
  • Save & Deploy the field to update the layout.
Studio is a developer tool for modifying the subpanel layouts in SugarCRM

Here we go we can see the field in the members subpanel under the meetings module, but we are not yet done. We have to change the label of this field in the subpanels file.

Modifying the Field Label in the Subpanel File

To change the label of the field displayed in the Members subpanel under the Meetings Module, follow these steps

  • Navigate to the file path as mentioned below (.custom\modules\PSME_Members\clients\base\views\subpanel-for-meetings-meetings_psme_members_1\subpanel-for-meetings-meetings_psme_members_1.php)
  • Locate the array related to the ‘meeting_status’ field inside this file and Adjust the ‘label’ attribute in the array to change the field label as shown in the below.
array (
          'name' => 'meeting_status',
          'label' => 'Meeting Status',
          'enabled' => true,
          'default' => true,
  • Once this is done, we have to perform the Quick Repair and Rebuild. We are all set, now we are ready to use the relationship field and track members meeting status for a particular meeting.
  • After performing all the steps as mentioned in this blog, you can see the Meeting Status field in Members Subpanel under the Meetings module as shown in the below screenshot.
Adding the fields in the Subpanels in the custom modules through studio


In summary, custom role-based fields in CRM subpanels make it easier to understand different roles and help in making better decisions. Doing database operations and programming for these changes demonstrates the CRM system’s ability to adjust and improve how data is handled, leading to smarter business methods. Bhea is the trusted SugarCRM partner with extensive experience since 2004, specializes in implementing and supporting CRM systems tailored specifically to meet diverse business needs. As a leading authority in SugarCRM, Contact Us for all your CRM/SugarCRM implementation and support requirements.

Share this article
Shareable URL
Prev Post

Why Implementing CRM is essential to  the manufacturing industry

Next Post

What is SugarBPM – An Introduction

Leave a Reply

Your email address will not be published. Required fields are marked *

Read next