While setting up any CRM for a business we regularly come across situations where the visibility or access or mandatory condition for the field is dependent upon the input value / current value of another field, and implementation of such a feature can drastically impact the user experience, data validity, data integrity and process integrity and to some extent the system value for the organisation also.

Banner SugarCRM Services


How to define dependent fields within SugarCRM

SugarCRM comes with an extended feature to implement such dependencies directly onto the instance from the PHP in a future safe manner. Declared as dependencies in the architecture, it is a feature in SugarCRM implemented via extension.

There are 2 possible ways to implement this into the instance, both of which we will be discussing in detail in the following sections.

  • Field dependency via studio
  • Field dependency via code

Let us look at both the methods below with an example.

development services by VeonLearn more about our SugarCRM development services. View what we can do for you to automate your business and take it to a higher level.


Dependency Via Studio

Dependency via studio is a rather limited process in SugarCRM, which is available since the earlier version as old as 6.5. This process handles only the visibility criteria of a field, i.e. following this process, one can only make the field visible or invisible based upon the dependent fields value. The criteria for the dependency can be calculated using a formula which can be designed to check for a single value or among a list of value or a Boolean value. These formulas implemented directly at the JavaScript level, making it effective for users at the user interface level when he is using the particular module in which the dependency is implemented. The steps for implementing dependency on a field via Studio are listed as below.

  • Login as a system admin user
  • Go to Administrator > Studio > <module> > Field List > Field to be made invisible
  • If a drop-down type field, then select ‘formula’ for parameter ‘Dependent’

Screenshot of select formula for parameter Dependent

  • If the field is a text field type, then select the checkbox for parameter ‘Dependent’

Screenshot of select the checkbox for parameter Dependent

  • You will be shown a formula field where you can enter your criteria for the visibility of the field. The formula can also be created using the formula builder panel provided by SugarCRM (The outcome of the formula should a Boolean type, for the formula to be effective)

Screenshot of formula builder panel

  • Then save the formula, save field and you are done
  • The changes will be effective from the next reload of the record view of the module

Learn SuiteCRM in 20 Minutes


Dependency Via Code

This is the more versatile, in-depth and granular level for defining a dependency for the field. Unlike the studio method of dependency, in the code level, you can define a dependency for ‘SetVisibility’, ‘SetRequired’, ‘SetValue’, ‘ReadOnly’, ‘SetOptions’, ‘SetPanelVisibility’. For the course of this article, we will discuss ‘SetVisibility’ and ‘SetRequired’, how to implement these individually and simultaneously for the same field, using sugar extension architecture for upgrade safe development.

Only ‘SetVisibility’ for custom field

For this example, we are going to implement ‘SetVisibility’ criteria in Leads module on a custom field ‘closed_lost_reason_c’, with visibility criteria that value of field ‘de_lead_status_c’ is equal to ‘Qualified_No’, and the criteria will be triggered for change in selected value for ‘de_lead_status_c’ field. The steps are as followed

  • Create a new file at the following locations
    <sugar instance>/custom/Extension/modules/Leads/Ext/Dependencies/<filename>.php
  • Add the following code to the file

  • Do a Quick Repair and Rebuild
  • The dependency will be effective in the record view on the next reload

Only ‘SetRequired’ for custom field

For this example, we are going to implement ‘SetRequired’ criteria in Leads module on a custom field ‘closed_lost_reason_c’, with required criteria that value of field ‘de_lead_status_c’ is equal to ‘Qualified_No’, and the criteria will be triggered for change in selected value for ‘de_lead_status_c’ field. The steps are as followed

  • Create a new file at the following locations
    <sugar instance>/custom/Extension/modules/Leads/Ext/Dependencies/<filename>.php
  • Add the following code to the file

  • Do a Quick Repair and Rebuild
  • The dependency will be effective in the record view on the next reload

Only ‘SetRequired’ and ‘SetVisibility’ for custom field

For this example, we will implement the above 2 code in the same file for the same field. The steps are as followed

  • Create a new file at the following locations
    <sugar instance>/custom/Extension/modules/Leads/Ext/Dependencies/<filename>.php
  • Add the following code to the file

  • Do a “Quick Repair” and “Rebuild”
  • The dependency will be effective in the record view on the next reload

Dependency and filter will always be a part of all the effective systems, making the data and the business process for the valuable and usable for the organisations. Implementing them effectively and upgrade safe manner is what will give the system the longevity of life and value.


Evaluating SugarCRM for your business – We can help

Reach out to us so that we can assess and plan a road-map for your CRM implementation. Let’s build a system, which you will use for years to come.

Contact us for a free assessment