Stephen Nielsen
Stephen Nielsen

Reputation: 167

Enabling Global Search on Custom module with sugarCRM 6.5+

I have been searching and cannot seem to find the solution. I am running 6.5.15 CE on a lamp stack, I have created 2 custom modules in module builder and edited them in studio. Customers and orders, the orders module shows as a sub panel to the customers module. I have Global search working just fine with the customers module but not the orders module. First I tried an example that states to create the following page /custom/Extension/modules/cb_orders/ext/Vardefs/customGlobalSearchFields.php that did not work, so I have added module and field names to the custom/modules/cb_orders/EXT/Vardefs/vardefs.php

<?php
// define custom fields to be included in the search algorithm!
$dictionary['cb_orders']['unified_search'] = true;
$dictionary['cb_orders']['unified_search_default_enabled'] = true;
// order number
$dictionary['cb_orders']['fields']['cb_order_number']['rname'] = 'cb_order_number';
$dictionary['cb_orders']['fields']['cb_order_number']['vname'] = 'LBL_CB_ORDER_NUMBER';
$dictionary['cb_orders']['fields']['cb_order_number']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['cb_order_number']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['cb_order_number']['table'] = 'cb_orders';
$dictionary['cb_orders']['fields']['cb_order_number']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;
// tracking number
$dictionary['cb_orders']['fields']['cb_shipping_tracking_number']['rname'] =    'cb_shipping_tracking_number';
$dictionary['cb_orders']['fields']['cb_shipping_tracking_number']['vname'] = 'LBL_CB_SHIPPING_TRACKING_NUMBER';
$dictionary['cb_orders']['fields']['cb_shipping_tracking_number']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['cb_shipping_tracking_number']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['cb_shipping_tracking_number']['table'] = 'cb_orders';
$dictionary['cb_orders']['fields']['cb_shipping_tracking_number']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;
// order description
$dictionary['cb_orders']['fields']['order_description']['rname'] = 'order_description';
$dictionary['cb_orders']['fields']['order_description']['vname'] = 'LBL_ORDER_DESCRIPTION';
$dictionary['cb_orders']['fields']['order_description']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['order_description']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['order_description']['table'] = 'cb_orders';
$dictionary['cb_orders']['fields']['order_description']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;
// shipping company used
$dictionary['cb_orders']['fields']['cb_orders_shipping_company']['rname'] = 'cb_orders_shipping_company';
$dictionary['cb_orders']['fields']['cb_orders_shipping_company']['vname'] = 'LBL_CB_ORDERS_SHIPPING_COMPANY';
$dictionary['cb_orders']['fields']['cb_orders_shipping_company']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['cb_orders_shipping_company']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['cb_orders_shipping_company']['table'] = 'cb_orders';
$dictionary['cb_orders']['fields']['cb_orders_shipping_company']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;
// which cart the order came from
$dictionary['cb_orders']['fields']['cb_referrer_c']['rname'] = 'cb_referrer_c';
$dictionary['cb_orders']['fields']['cb_referrer_c']['vname'] = 'LBL_CB_REFERRER';
$dictionary['cb_orders']['fields']['cb_referrer_c']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['cb_referrer_c']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['cb_referrer_c']['table'] = 'cb_orders';
$dictionary['cb_orders']['fields']['cb_referrer_c']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;
// date and time ordered
$dictionary['cb_orders']['fields']['date_time_ordered_c']['rname'] = 'date_time_ordered_c';
$dictionary['cb_orders']['fields']['date_time_ordered_c']['vname'] = 'LBL_DATE_TIME_ORDERED';
$dictionary['cb_orders']['fields']['date_time_ordered_c']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['date_time_ordered_c']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['date_time_ordered_c']['table'] = 'cb_orders_cstm';
$dictionary['cb_orders']['fields']['date_time_ordered_c']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;
// last four of social
$dictionary['cb_orders']['fields']['cb_lastfour_c']['rname'] = 'cb_lastfour_c';
$dictionary['cb_orders']['fields']['cb_lastfour_c']['vname'] = 'LBL_CB_LASTFOUR';
$dictionary['cb_orders']['fields']['cb_lastfour_c']['type'] = 'TextField';
$dictionary['cb_orders']['fields']['cb_lastfour_c']['dbType'] = 'varchar';
$dictionary['cb_orders']['fields']['cb_lastfour_c']['table'] = 'cb_orders_cstm';
$dictionary['cb_orders']['fields']['cb_lastfour_c']['unified_search_default_enabled'] = true;
//$dictionary['cb_orders']['unified_search'] = true;

file and the custom/modules/cb_orders/metadata/searchfields.php file as shown in examples on the sugar forum.

$searchFields['cb_orders']['cb_order_number'] = array('query_type' => 'default');
$searchFields['cb_orders']['cb_shipping_tracking_number'] = array('query_type' => 'default');
$searchFields['cb_orders']['order_description'] = array('query_type' => 'default');
$searchFields['cb_orders']['cb_orders_shipping_company'] = array('query_type' => 'default');
$searchFields['cb_orders']['cb_referrer_c'] = array('query_type' => 'default');
$searchFields['cb_orders']['date_time_ordered_c'] = array('query_type' => 'default');

After a rebuild I still do not seem to be able to search that module.

Could this be caused because of the one to many relationship (one-customers to many-orders)?

Upvotes: 1

Views: 1812

Answers (2)

Z00tj3
Z00tj3

Reputation: 81

I had to remove /cache/modules/unified_search_modules.php additionally to get it working. After removing it will be generated again after searching.

Upvotes: 1

Ramblin
Ramblin

Reputation: 181

I do not know if you ever got this working or not, but I noticed that you have, as your path

custom/modules/cb_orders/metadata/searchfields.php

when it should be

custom/modules/cb_orders/metadata/SearchFields.php

(capital S and F in SearchFields.php)

As far as the first path

custom/Extension/modules/cb_orders/ext/Vardefs/customGlobalSearchFields.php

you can use any file name, it does not have to be vardefs.php Check the

custom/modules/cb_orders/Ext/Vardefs/vardefs.ext.php 

file to confirm the additions were captured in the Repair and Rebuild, regardless of the file name.

Did you ever get this working without needing to also do a admin -> Global Search -> Drag&Drop ?

Upvotes: 2

Related Questions