How can I add more types of currencies in the currency type field?

I have created a custom module with a currency type field.

When editing a record, a field for the value and a field for the currency type are displayed as a dropdown

I now need to add a new type of currency

For this purpose I have added a new entry in Admin > System > Currencies, in my case Pounds

But when editing a module record in the currency types dropdown only the currency is shown by default

How can I add more types of currencies in the currency type field?

I notice that in the module’s vardef there is the currency_id field that calls a getCurrencyDropDown function

Thanks in advance

Hello, I hope this help!

1. Update the Field Definition:

Open the vardef file for your custom module. Look for the definition of the currency type field (currency_id)

'currency_id' => array(
    'name' => 'currency_id',
    'vname' => 'LBL_CURRENCY',
    'type' => 'currency',
    // ... other properties ...

2. Modify getCurrencyDropDown Function:

In your module’s vardefs.php file, you might have a function named getCurrencyDropDown that is responsible for retrieving the currency dropdown values. Find and modify this function to include your new currency type.

'currency_id' => array(
    'name' => 'currency_id',
    'vname' => 'LBL_CURRENCY',
    'type' => 'currency',
    'options' => 'currency_dom', // or 'getCurrencyDropDown' function
    'default' => 'USD',

3. Update the getCurrencyDropDown Function:

If the currency dropdown values are retrieved through a function, locate that function in your custom module or a related file. Ensure it includes the new currency type (Pounds) that you added in the Admin panel. Make sure to adapt this function according to the structure of your existing code.

function getCurrencyDropDown()
    $currency_options = parent::getCurrencyDropDown();
    // Add your custom currency (Pounds)
    $currency_options['Pound'] = 'Pound';
    return $currency_options;

4. Quick Repair and Rebuild:

After making these changes, perform a Quick Repair and Rebuild in the Admin panel. This step will help SugarCRM to reflect the changes you made to the vardefs.

Go to Admin > Repair > Quick Repair and Rebuild.

Click on “Quick Repair and Rebuild” button.