For a recent project I needed an upgrade safe way to populate a dropdown from a database table in SugarCRM. In this case, the dropdown was a custom field that needed to contain a list of projects that where templates so that a user can create a new project based off of an existing project template. I’m going to make this short but sweet.
First the custom field definition via the vardefs extension (defined by the ‘vardefs’ array in a manifest.php if making an installable module):
Notice the function definition. This will be the next step.
(Following is defined in the ‘utils’ array in a manifest.php if making an installable module)
In the custom function an array is returned with the select option values as the key and the option labels as the value.
Note: if you manually add the files to the custom/Extension directory make sure to run a Repair/Rebuild for the changes to propagate through.
Note 2: For SugarCRM 6.3 and up only