Auto Populating The Related Module’s Field Data in The Current Module

We often have a requirement to populate the fields data of the related module on change of the related field in the current module. Let us take an example here. We have a parent-child relationship between the Accounts and Contacts module (one too many relationships). Although SugarCRM’s default address auto-population from Account to Contact is helpful, it doesn’t stop there. We often encounter scenarios where we need to go beyond just addresses and populate other crucial fields from the Account as well.


Let us take an example here:

If we want to populate the data to the Office Phone field in the Contacts module the same as the office phone in the Accounts module. As a result, using the populate_list makes this process simple. It triggers the logic whenever the account is changed in the Contact or linked to it.

Step 1:

Create the file in the below path and add this code../custom/Extension/modules/Contacts/Ext/Vardefs/
$dictionary[‘Contact’][‘fields’][‘account_name‘][‘populate_list’][ ‘phone_work’] = ‘phone_office’;
Let us understand a bit more about the parameters used in this file.

Fetch Data from the related module in SugarCRM
  • account_name refers to the relationship name of the Contacts and Accounts.
  • phone_work is the field name of the Office Phone field in the Contacts module.
  • phone_office is the field name of the Office Phone field in the Accounts module.

This code can be utilize for any type of the field in any module. Make sure we are using the correct relationship names and field names when we are adding the code in the Vardefs.

Step 2:

Make sure you have proper permissions for all your file structure in the Sugar Root Directory. Now we have to perform the Quick Repair and Rebuild by navigating to the admin section in the SugarCRM instance.

Linking an Account to a Contact Record populates the Office Phone field with data from the Account.

Share this article
Shareable URL
Prev Post

SugarCRM Tutorial on categorizing records in two Subpanels for a single “One to Many” relationship

Next Post

SugarCRM Developer Tutorial on Creating Many-to-Many Relationship in Product Catalogue Module

Read next