Problem exporting account when filter is applied

Hi everybody:

I’ve found a problem, maybe a bug, when I tried to export an accounts list after applied a filter by campaign name. This is the way to reproduce the problem:

  1. Add the field ‘campaign_name’ to the available fields on layaouts filter and list views using studio
  2. Filter accounts by any campaign, filter works fine
  3. Select all accounts after filter and export them using export on ‘bulk action’ menu
  4. The page goes blank

As I see on suitecrm.log file, there are a problem with the SQL query:

Query Failed: 
		accounts.*, email_addresses.email_address email_address, '' email_addresses_non_primary, as account_name,
		users.user_name as assigned_user_name ,accounts_cstm.jjwg_maps_lng_c,accounts_cstm.jjwg_maps_lat_c,accounts_cstm.jjwg_maps_geocode_status_c,accounts_cstm.jjwg_maps_address_c 
		accounts LEFT JOIN users
		LEFT JOIN  email_addr_bean_rel 
			on = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Accounts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1  
		LEFT JOIN email_addresses 
			on = email_addr_bean_rel.email_address_id  
		LEFT JOIN accounts_cstm 
			ON = accounts_cstm.id_c 
		((campaign_name like 'CAMPAIGN1%')) AND ( accounts.deleted IS NULL OR accounts.deleted=0 )
		: MySQL error 1054: Unknown column 'campaign_name' in 'where clause'
Fri Jan 12 17:18:16 2018 [10499][d7feffe7-41cb-10c1-d063-5a37de0929cc][FATAL] Exception handling in /var/www/html/include/MVC/Controller/SugarController.php:402
Fri Jan 12 17:18:16 2018 [10499][d7feffe7-41cb-10c1-d063-5a37de0929cc][FATAL] Exception in Controller: Database failure. Please refer to suitecrm.log for details.
Fri Jan 12 17:18:16 2018 [10499][d7feffe7-41cb-10c1-d063-5a37de0929cc][FATAL] backtrace:
#0 /var/www/html/include/database/DBManager.php(353): sugar_die('Database failur...')
#1 /var/www/html/include/database/DBManager.php(328): DBManager->registerError('Error exporting...', 'Error exporting...', true)
#2 /var/www/html/include/database/MysqliManager.php(160): DBManager->checkError('Error exporting...', true)
#3 /var/www/html/include/export_utils.php(172): MysqliManager->query('SELECT\n        ...', true, 'Error exporting...')
#4 /var/www/html/export.php(67): export('Accounts')
#5 /var/www/html/include/MVC/Controller/SugarController.php(1014): require_once('/var/www/html/a...')
#6 /var/www/html/include/MVC/Controller/SugarController.php(465): SugarController->handleEntryPoint()
#7 /var/www/html/include/MVC/Controller/SugarController.php(373): SugarController->process()
#8 /var/www/html/include/MVC/SugarApplication.php(105): SugarController->execute()
#9 /var/www/html/index.php(52): SugarApplication->execute()
#10 {main}

There is clear that the where clause is trying to search all records where ‘campaign_name’ is like the desired Campaign Name, but the column campaign_name does not exist on accounts table or any other table on this query.

Have anyone done something like that or know how to solve this issue? maybe would be better to report it as a bug?

Thanks for your help.

Hi, thanks for the report.

Do you see any Apache errors in php_errors.log? There should be something there if you had a white screen of death.


the only error I see on ssl_error_log is:

[Mon Jan 15 10:20:34.578925 2018] [:error] [pid 9557] [client] PHP Notice:  Only variables should be passed by reference in /var/www/html/include/export_utils.php on line 556, referer:

not too much

When you do a Quick Repair and Rebuild, scroll down to the bottom and check if it gives you a button to sync vardefs with database. if it’s there, press it, then try again.

Hi @pgr,

When I do Quick Repair and Rebuild at the botton it says:

Database tables are synced with vardefs

Return to Administration page


If you look directly in the database (via phpMyAdmin or MySQL command-line) do you see a column campaign_name in “accounts” or “accounts_cstm” tables?

Sorry, I’ve already check at it, but in ‘accounts’ table there is only a field called ‘campaign_id’, and in ‘accounts_cstm’ there is no field similar to ‘campaign_name’.



It looks like the field is not correctly deployed by Studio, it seems incomplete.

Can you try more repairs from Admin / Repairs?

And perhaps try deleting the field and re-creating it? Of, course, you will lose any data you have there, but I suspect you don’t have any (if it’s not in the database…)

You might have to clear some left-overs from a previously failed deployment - some vardef file, or a row in table fields_meta_data

I have the same problem!. It seems to be a bug on PHP 7 using the “Select All” option using filter from related module. This doesn’t happen if I use instead the “Select this page” or if I select the rows one by one and then hit the Bulk action -> Export.


Hi, pgr:

I’ve run all the repairs available, deploy again the module, etc., but the problem persist, I will open a bug report for this problem.

Thanks for your help.


Just for reference, this is the Issue opened by David

Just for everyone to know, look like this bug is still there if the related field filtered is from the same module ?

Reply here :