【问题标题】:Global Search on Custom field in SugarCRM or SuiteCRMSugarCRM 或 SuiteCRM 中自定义字段的全局搜索
【发布时间】:2018-01-27 04:25:07
【问题描述】:

我在 Accounts 模块上有一个名为 code 的自定义字段,我想在全局搜索中启用它,以便在搜索栏中输入不带通配符的搜索。

假设我有一些记录,其值为“88990”、“23477”和“12347”。 如果有人使用全局搜索并输入 347,它应该将代码 23477 和 12347 的帐户返回给我。 我不想输入 %347 哟结果。 我怎样才能做到这一点? 我有代码 custom/Extension/modules/Account/Ext/Vardefs/sugarfield_code_c.php

$dictionary['Account']['fields']['code_c']['inline_edit']='1';
$dictionary['Account']['fields']['code_c']['labelValue']='test code';
$dictionary['Account']['fields']['code_c']['unified_search']=true;

在 custom/modules/Accounts/SearchFields.php 我有

$searchFields['Accounts'] = array(
    'code_c' =>
        array(
            'query_type' => 'default'
        )
        );

【问题讨论】:

    标签: php sugarcrm suitecrm


    【解决方案1】:

    SuiteCRM 版本: 7.10.4

    解决方案不安全。

    导航到 include/SearchForm/SearchForm2.php 并在 generateSearchWhere() 函数中查找以下内容:

    $where .= $this->seed->db->concat($concat_table, $concat_fields) . " LIKE " . $this->seed->db->quoted($field_value . $like_char);
    $where .= ' OR ' . $this->seed->db->concat($concat_table, array_reverse($concat_fields)) . " LIKE " . $this->seed->db->quoted($field_value . $like_char);
    

    我更改了这一行以在$field_value 之前连接$like_char 变量:

    $where .= $this->seed->db->concat($concat_table, $concat_fields) . " LIKE " . $this->seed->db->quoted($like_char . $field_value . $like_char);
    $where .= ' OR ' . $this->seed->db->concat($concat_table, array_reverse($concat_fields)) . " LIKE " . $this->seed->db->quoted($like_char . $field_value . $like_char);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-07
      • 1970-01-01
      • 2013-05-15
      • 1970-01-01
      相关资源
      最近更新 更多