Hi @jdelgado ,
Did you set a filter to a relate field? (field of another module)
This is currently not supported and also described here:
When i add this filter to Targets module and search, it is working good. But when i try to exports all list, there is a database error. What is wrong?
“Database failure. Please refer to suitecrm.log for details.”
In log:
Sun Dec 6 22:35:20 2020 [20131][e433d2f0-c23e-3ad2-bd4d-5ee727929421][FATAL] Mysqli_query failed.
Sun Dec 6 22:35:20 2020 [20131][e433d2f0-c23e-3ad2-bd4d-5ee727929421][FATAL] Error exporting Prospects: .SELECT
prospects.,
email_addresses.email_address email_address,
‘…
Github issue:
opened 03:36PM - 07 Dec 20 UTC
Type: Bug
Priority:Critical
Area: Module
#### Issue
When i add custom Target list filter to Target module, it is wor… king good. But when i select all records from bulk action menu and export them, there is an error which is Database failure. But when i select records of first page and exports, it is working good.
#### Expected Behavior
It should be working as expected.
#### Actual Behavior
#### Possible Fix
#### Steps to Reproduce
1. Add custom target list filter to Targets module
Add the file:
`custom/Extension/modules/Prospects/Ext/Vardefs/targetlistfilter.php`
with content:
`<?php
$dictionary['Prospect']['fields']['prospect_list_name'] = array (
'name' => 'prospect_list_name',
'rname' => 'name',
'id_name' => 'prospect_list_id',
'vname' => 'LBL_PROSPECTLIST_NAME',
'type' => 'relate',
'link' => 'prospect_lists',
'table' => 'prospect_lists',
'isnull' => 'true',
'module' => 'ProspectLists',
'dbType' => 'char',
'len' => '255',
'source' => 'non-db',
'duplicate_merge'=> 'disabled',
);`
Add the file:
`custom/Extension/modules/Prospects/Ext/Language/en_us.targetlistfilter.php`
with content:
`<?php
$mod_strings['LBL_PROSPECTLIST_NAME'] = 'Target List:';`
Afterwards, do a Admin / Repair / Quick Repair and Rebuild
2. Open Studio, module Contacts / Layouts / Filter
The filter field Target List is now available in the Hidden list and can be added to the Quick Filter and the Advance Filter layout.
3. Open Target module and filter with "Target List" field

4. Select all results

5. Then export them via Bulk Action Menu

6.See result

7. Suitecrm log;
`Mon Dec 7 17:52:06 2020 [30995][e433d2f0-c23e-3ad2-bd4d-5ee727929421][FATAL] Mysqli_query failed.
Mon Dec 7 17:52:06 2020 [30995][e433d2f0-c23e-3ad2-bd4d-5ee727929421][FATAL] Error exporting Prospects:
.SELECT
prospects.,
email_addresses.email_address email_address,
‘’ email_addresses_non_primary, users.user_name as assigned_user_name ,prospects_cstm.jjwg_maps_geocode_status_c,prospects_cstm.jjwg_maps_lng_c,prospects_cstm.jjwg_maps_lat_c,prospects_cstm.target_tag_c,prospects_cstm.jjwg_maps_address_c FROM prospects LEFT JOIN users
ON prospects.assigned_user_id=users.id LEFT JOIN email_addr_bean_rel on prospects.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module = ‘Prospects’ and email_addr_bean_rel.deleted = 0 and email_addr_bean_rel.primary_address = 1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id LEFT JOIN prospects_cstm ON prospects.id = prospects_cstm.id_c WHERE ((prospect_list_name like ‘15 ŞUBAT 2018 KONFERANS KATILIMCI LİSTESİ%’)) AND prospects.deleted=0 Query Failed: SELECT
prospects.,
email_addresses.email_address email_address,
‘’ email_addresses_non_primary, users.user_name as assigned_user_name ,prospects_cstm.jjwg_maps_geocode_status_c,prospects_cstm.jjwg_maps_lng_c,prospects_cstm.jjwg_maps_lat_c,prospects_cstm.target_tag_c,prospects_cstm.jjwg_maps_address_c FROM prospects LEFT JOIN users
ON prospects.assigned_user_id=users.id LEFT JOIN email_addr_bean_rel on prospects.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module = ‘Prospects’ and email_addr_bean_rel.deleted = 0 and email_addr_bean_rel.primary_address = 1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id LEFT JOIN prospects_cstm ON prospects.id = prospects_cstm.id_c WHERE ((prospect_list_name like ‘15 ŞUBAT 2018 KONFERANS KATILIMCI LİSTESİ%’)) AND prospects.deleted=0 : MySQL error 1054: Unknown column ‘prospect_list_name’ in ‘where clause’
Mon Dec 7 17:52:06 2020 [30995][e433d2f0-c23e-3ad2-bd4d-5ee727929421][FATAL] Exception handling in /var/www/sucrm/crm/include/MVC/Controller/SugarController.php:400
Mon Dec 7 17:52:06 2020 [30995][e433d2f0-c23e-3ad2-bd4d-5ee727929421][FATAL] Exception in Controller: Database failure. Please refer to suitecrm.log for details.
Mon Dec 7 17:52:06 2020 [30995][e433d2f0-c23e-3ad2-bd4d-5ee727929421][FATAL] backtrace:
#0 /var/www/sucrm/crm/include/database/DBManager.php(353): sugar_die(‘Database failur…’)
#1 /var/www/sucrm/crm/include/database/DBManager.php(328): DBManager->registerError(‘Error exporting…’, ‘Error exporting…’, true)
#2 /var/www/sucrm/crm/include/database/MysqliManager.php(179): DBManager->checkError(‘Error exporting…’, true)
#3 /var/www/sucrm/crm/include/export_utils.php(194): MysqliManager->query(‘SELECT\n\t\t\t\t\tpro…’, true, ‘Error exporting…’)
#4 /var/www/sucrm/crm/export.php(69): export(‘Prospects’)
#5 /var/www/sucrm/crm/include/MVC/Controller/SugarController.php(1020): require_once(’/var/www/sucrm/…’)
#6 /var/www/sucrm/crm/include/MVC/Controller/SugarController.php(468): SugarController->handleEntryPoint()
#7 /var/www/sucrm/crm/include/MVC/Controller/SugarController.php(373): SugarController->process()
#8 /var/www/sucrm/crm/include/MVC/SugarApplication.php(113): SugarController->execute()
#9 /var/www/sucrm/crm/index.php(52): SugarApplication->execute()
#10 {main}`
#### Context
#### Your Environment
* SuiteCRM Version used: 7.11.15
* Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Firefox 83 (64 bit)
* Environment name and version (e.g. MySQL, PHP 7): Php 7
* Operating System and version (e.g Ubuntu 16.04): Ubuntu 16.04
You could fix the export by applying the suggested changes, but they have side effects. I was working on a fix, but it is not as straightforward as I hoped.
You might want to try creating a report with the selected filters and exporting from this report.