What is the correct way to change the name of a custom field?

I have created a custom field using the using extension strategy. Example

At suitecrm/custom/Extension/modules/some_module_name/Ext/Vardefs/some_field_name.php

$dictionary["some_module_name"]["fields"]["some_field_name_c"] = [
     'name' => 'some_field_name_c',
     'vname' => 'LBL_SOME_FIELD_NAME',
     'type' => 'enum',
     'options' => 'some_list'
     'len' => 255
];

Now I need to rename this field

To this end I have tried the following

$dictionary["some_module_name"]["fields"]["some_field_name_c"] = [
     'name' => 'new_field_name_c',
     'vname' => 'LBL_SOME_FIELD_NAME',
     'type' => 'enum',
     'options' => 'some_list'
     'len' => 255
];

also

$dictionary['some_module_name']['fields']['some_field_name_c']['name'] = 'new_field_name_c';

In both cases when repairing I get this message

ALTER TABLE some_module_name add COLUMN new_field_name_c varchar(255) NULL ;

I understand this will create a new field. But in my case I want to edit the name of the existing field

What is the correct way to change the name of a custom field?

Thanks in advance

Hello @mario.martinez

Thank you for your question. I understand you’d like to change the name of a custom field in SuiteCRM. Here’s a step-by-step guide to achieve this:

Step 1: Change the Vardefs File

  • Navigate to the extensions directory (custom/Extension/modules/some_module_name/Ext/Vardefs/).
  • Modify the some_field_name.php file with the new field name:
$dictionary["some_module_name"]["fields"]["new_field_name_c"] = [
    'name' => 'new_field_name_c',
    'vname' => 'LBL_SOME_FIELD_NAME',
    'type' => 'enum',
    'options' => 'some_list',
    'len' => 255,
];

// Remove the old field definition
unset($dictionary["some_module_name"]["fields"]["some_field_name_c"]);

This step ensures that SuiteCRM recognizes the change as a renaming.

Step 2: Run a Repair and Rebuild

  • After making the changes, run a “Repair and Rebuild” from the Admin panel in SuiteCRM. This will execute the necessary SQL queries to reflect the field name change in the database.

Step 3: Clear the Cache

  • To ensure that SuiteCRM picks up the changes, clear the cache. You can do this manually by deleting the contents of the cache/ directory in the SuiteCRM installation or through the Admin panel.

After completing these steps, the field should be successfully renamed.

I hope this helps. If you have more questions, feel free to ask.

Best regards,
@chirag_biz309

1 Like

How is that answer different from what he already did?

I would suggest a simple additional step: change the name yourself directly in the database.