Let’s suppose you want to make Mobile field readonly based on Title field’s value in Contacts Module. You can achieve above with SugarCRM Dependencies. Experienced SugarCRM developers already know about Dependencies but if you are not familiar with them, no worries and carry on reading! These are used to add dependent actions to fields and forms that can leverage more complicated logic that is not yet available in Studio. More information about dependency actions can be found in the Sugar Logic section. As mentioned in properties of Dependencies the dependency files should be located in ./custom/Extension/modules/{module}/Ext/Dependencies/{dependency name}.php and be rebuilt with a quick repair after modification. As we are going to add a dependency for Contacts Module we will be creating a dependency file at custom/Extension/modules/Contacts/Ext/Dependencies Inside the file put below code Save the file and do a quick repair and rebuild. The dependency we just created says that the Mobile Phone Field will be readonly if the Title of the person is CTO. This works perfectly in Sugar 6 and seems to partially work in Sugar 7 How to make certain field readonly or disabled based on some other field’s value using SugarCRM Dependencies
Last modified
SugarCRM Dependencies:
Properties:
Internal Name
dependencies
Manifest Installdef
dependencies
Extension Directory
./custom/Extension/modules/<module>/Ext/Dependencies/
Extension File
./custom/modules/<module>/Ext/Dependencies/deps.ext.php
Adding Dependency to Contacts Module:
$dependencies['Contacts']['phone_mobile_readonly'] = array(
'hooks' => array("edit"),
'trigger' => 'equal($title, "CTO")', //Optional, the trigger for the dependency. Defaults to 'true'.
'triggerFields' => array('title'),
'onload' => true,
//Actions is a list of actions to fire when the trigger is true
'actions' => array(
array(
'name' => 'ReadOnly',
//The parameters passed in will depend on the action type set in 'name'
'params' => array(
'target' => 'phone_mobile',
'value' => 'true',
),
),
),
);
5 min read