If you move instances of SuiteCRM around it’s possible to have a copy of the SuiteCRM files that reference a custom field that doesn’t exist in the fields_meta_data table.

This can cause broken SQL queries since SuiteCRM will try to reference a field but won’t have it’s name. A broken query may look something like:

UPDATE my_custom_module SET name='Foo', =NULL,=NULL WHERE id='1234';

This can be fixed in one of two ways.

The first, preferred way is to get the info from the fields_meta_data table. This mysqldump command will create a file with the fields meta data:

mysqldump -uYourDBUser --insert-ignore --no-create-info -p YourDB fields_meta_data > fields_meta_data.sql

This can then be used to populate the new DB:

mysql -uYourDBUser -p YourNewDB < fields_meta_data.sql

The second is to find and remove the fields which are causing the issue. The following script will list any entries in the vardefs without a name which causes the original broken queries. Simply change the \$base variable to be the path to the SuiteCRM instance you want to check and run php -f fieldcheck.php:


$base = "/path/to/suitecrm";
$searchBase = $base.DIRECTORY_SEPARATOR."cache".DIRECTORY_SEPARATOR."modules";
$dirs = scandir($searchBase);
$GLOBALS["dictionary"] = array();
foreach($dirs as $dir){
    $dir = $searchBase .DIRECTORY_SEPARATOR . $dir;
    if($dir == '.' || $dir == '..' || !is_dir($dir)){

    $files = glob($dir.DIRECTORY_SEPARATOR.'*vardefs.php');
    foreach($files as $file){
        include $file;
foreach($GLOBALS["dictionary"] as $module => $arr){
    foreach($arr["fields"] as $key => $field){
            echo "Empty key for field in $module\n";
            echo "Empty name for $key field in $module\n";

Once you have found the offending fields you can remove the definitions for them.