A few months back I shared a simple example that demonstrated said simplicity quite well through a customization of the search popup windows. Let us take a look at another equally simple and useful modification.
This time around we are going to look at something just as easy, but serving a completely different purpose.
In this scenario we will assume that we have a need to create a read-only field, one that cannot be edited via the SugarCRM interface. This is helpful for scenarios where records may contain important data that should not be changed by any user. A good example of this is financial data from external systems, such as your ERP solution.
Because this data is coming from another system, it is usually input into SugarCRM by means of a link or other programmatic approach that eliminates the need for the user to actually enter the data by editing the record.
Allowing users to manipulate the values would create the potential for faulty analysis. For example, if one of the values relates to a customer's outstanding balance, a user could accidentally (or purposely) increase or decrease it, in turn misleading the next person that views said record. Hence the value of using a read-only field.
Converting a field into a read-only field is quite simple. Read on to see the step-by-step instructions.
To begin with, let us select a field. For our example we will pretend we have created and will be using a custom field named "member_status_c" which already exists on the Edit and Detail view screens. It holds one of two values: current and expired and is part of the Contacts module.
Converting it into a read-only field is quite simple.
First, create a new PHP file and name it vardefs.ext.php and add the following code to it:
$dictionary['contact']['fields']['member_status_c']['type'] = 'readonly';
Save the file and place a copy of it in the following folder:
Lastly, you need to instruct SugarCRM to apply the settings by means of a repair operation. To complete the process:
- Login as an Admin level user
- Click Admin > Repair > Quick Repair and Rebuild
- Select Contacts in the Modules list and click Repair
Congrats! Simple, no?