Last Updated:

SugarCRM: Global Search for custom module and field

Dạy Seo Web

(Anhgolden's Blog)-Để SugarCRM Search hay Global Search của SugarCRM có thể tìm thấy thông tin trên 1 filed mới hoặc module mới, xin chia sẻ cách thực hiện như sau:

Bạn nên tìm hiểu thêm ở bài viết này http://developers.sugarcrm.com/wordpress/2011/03/30/new-in-sugar-6-2-global-search-custom-modules/ và cùng trải nghiệm ví dụ thực tế của tôi.

Tôi có 1 nhu cầu bổ sung thêm 1 field có tên đặt là "Contact_ID" trong module Contact.

B1: Vào Admin - Studio - Chọn Module Contacts - Add new field

Lưu ý: kết quả Field name là "contact_id_c"

B2: Điều chỉnh layout theo nhu cầu. Bổ sung field "Contact_ID" vào Edit View, Details View và List View

B3: Create or edit file custom/Extension/modules/YOUR_CUSTOM_MODULE/Ext/Vardefs/vardefs.php and add the unified_search attributes to the fields you wish to run global search on:

Cụ thể:

Lưu ý: 'Contact' không có 's'.

B4: Create or edit the file custom/modules/YOUR_CUSTOM_MODULE/metadata/SearchFields.php. If you are creating this file, you may simply copy the modules/YOUR_CUSTOM_MODULE/metadata/SearchFields.php file into the custom/modules/YOUR_CUSTOM_MODULE/metadata directory. Add your field to the search definitions:
‘NAME_OF_FIELD_TO_SEARCH’ => array( ‘query_type’=>’default’)

$searchFields['Contacts'] =array ('first_name' => array( 'query_type'=>'default'),'last_name'=> array('query_type'=>'default'),'contact_id_c'=> array('query_type'=>'default'),

B5: Repair and Rebuild