salesagility / SuiteCRM-Core

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
180 stars 133 forks source link

SuiteCRM 8.2.4 doesn't search in custom fields #262

Open vladaman opened 1 year ago

vladaman commented 1 year ago

We've created new custom field. When trying to search by a value the record is not found. We've reindexed, removed caches etc. Still not working. Using Basic Search.

johnM2401 commented 1 year ago

Hey

When submitting an issue, please stick to the form provided to give as much information as possible.

We need some more information, such as:

I've given this a quick try with a Custom Text field, but it appears to filter as expected.

vladaman commented 1 year ago
  1. It doesn't matter which custom field I add - it's not included in the unified search (Basic Search)
  2. Affected Module: Accounts but it seems it's same behaviour for other modules
  3. PHP 8.1.2
  4. SuiteCRM 8.2.4
  5. Custom field has unified_search=true set both in:
    • legacy/custom/modules/Accounts/metadata/searchdefs.php
    • legacy/custom/modules/Accounts/Ext/Vardefs/vardefs.ext.php

Possible issue:

  1. public/legacy/custom/modules/Accounts/metadata/SearchFields.php does not include custom fields to be searched
  2. public/legacy/custom/modules/Accounts/metadata/metafiles.php file does not exist - therefore content from searchdefs.php was not included.

https://github.com/salesagility/SuiteCRM-Core/blob/1f949f1ac2b7fe82f3c2c6071f842b804ba91929/public/legacy/lib/Search/SearchModules.php#L230

Possible solution: How do I regenerate public/legacy/custom/modules/Accounts/metadata/SearchFields.php ? That would probably fix the issue

I checked the log and found that the Basic Search does not include any new field from accounts_cstm. Here is the SQL from log file:

SELECT accounts.id,
       accounts.modified_user_id,
       accounts.created_by,
       accounts.assigned_user_id,
       accounts.parent_id,
       accounts.campaign_id,
       accounts_cstm.account_id_c,
       accounts.name,
       accounts.date_entered,
       accounts.date_modified,
       jt0.user_name        modified_by_name,
       jt0.created_by       modified_by_name_owner,
       'Users'              modified_by_name_mod,
       jt1.user_name        created_by_name,
       jt1.created_by       created_by_name_owner,
       'Users'              created_by_name_mod,
       accounts.description,
       accounts.deleted,
       jt2.user_name        assigned_user_name,
       jt2.created_by       assigned_user_name_owner,
       'Users'              assigned_user_name_mod,
       accounts.account_type,
       accounts.industry,
       accounts.annual_revenue,
       accounts.phone_fax,
       accounts.billing_address_street,
       accounts.billing_address_city,
       accounts.billing_address_state,
       accounts.billing_address_postalcode,
       accounts.billing_address_country,
       accounts.rating,
       accounts.phone_office,
       accounts.phone_alternate,
       accounts.website,
       accounts.ownership,
       accounts.employees,
       accounts.ticker_symbol,
       accounts.shipping_address_street,
       accounts.shipping_address_city,
       accounts.shipping_address_state,
       accounts.shipping_address_postalcode,
       accounts.shipping_address_country,
       accounts.sic_code,
       jt3.name             parent_name,
       jt3.assigned_user_id parent_name_owner,
       'Accounts'           parent_name_mod,
       jt4.name             campaign_name,
       jt4.assigned_user_id campaign_name_owner,
       'Campaigns'          campaign_name_mod,
       accounts_cstm.jjwg_maps_geocode_status_c,
       accounts_cstm.ico_c,
       accounts_cstm.organization_tags_c,
       accounts_cstm.pgx_action_c,
       jt5.name             prirazeny_partner_c,
       accounts_cstm.jjwg_maps_address_c,
       accounts_cstm.jjwg_maps_lng_c,
       accounts_cstm.kontakt_c,
       accounts_cstm.kraj_c,
       accounts_cstm.jjwg_maps_lat_c,
       accounts_cstm.gclid_c,
       accounts_cstm.dic_c,
       accounts_cstm.ltv_eur_c,
       accounts_cstm.mcc_c
FROM accounts
         LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c
         LEFT JOIN users jt0 ON accounts.modified_user_id = jt0.id AND jt0.deleted = 0
    AND jt0.deleted = 0
         LEFT JOIN users jt1 ON accounts.created_by = jt1.id AND jt1.deleted = 0
    AND jt1.deleted = 0
         LEFT JOIN users jt2 ON accounts.assigned_user_id = jt2.id AND jt2.deleted = 0
    AND jt2.deleted = 0
         LEFT JOIN accounts jt3 ON accounts.parent_id = jt3.id AND jt3.deleted = 0
    AND jt3.deleted = 0
         LEFT JOIN campaigns jt4 ON accounts.campaign_id = jt4.id AND jt4.deleted = 0
    AND jt4.deleted = 0
         LEFT JOIN accounts jt5 ON accounts_cstm.account_id_c = jt5.id AND jt5.deleted = 0
where (((accounts.name like 'xxxxxxxxx%') OR (accounts.phone_office like 'xxxxxxxxx%') OR
        (accounts.id IN (select bean_id
                         from (SELECT eabr.bean_id
                               FROM email_addr_bean_rel eabr
                                        JOIN email_addresses ea ON (ea.id = eabr.email_address_id)
                               WHERE eabr.deleted = 0
                                 AND ea.email_address LIKE 'xxxxxxxxx%') email_derived))))
  AND accounts.deleted = 0
ORDER BY accounts.date_entered DESC
LIMIT 0,21