0

I have a few hundred custom fields to delete in an older version of SugarCRM. Is very labor intensive to delete through web interface...

Can this be done directly by deleting files in the instalation (vardefs, anything else?)

This is similar to [question asked earlier] (revert the custom fields made by sugarCRM), but was solved by using web interface for a few fields.

I can easily write a script then to remove the fields from the {table_name}_cstm tables...

Community
  • 1
  • 1
mgmonteleone
  • 400
  • 1
  • 9

1 Answers1

1

You can try something like that (should be execute in a SugarCRM environment like an entryPoint and with an admin user)

$fieldsByModule = array(
    'Accounts' => array(
        'field_1_c',
        'field_2_c',
    ),
    'Contacts' => array(
        'field_1_c',
        'field_2_c',
    ),
);

require_once('modules/DynamicFields/DynamicField.php');

foreach ($fieldsByModule as $moduleName => $fields) {
    foreach($fields as $field){
        $dyField = new DynamicField();
        $dyField->bean = BeanFactory::getBean($moduleName);;
        $dyField->module = $moduleName;
        $dyField->deleteField($field);
    }
}

Live coding without test the code but the core of the process should be near like that.