SugarCRM Customization : How To Extend ListView Query


SugarCRM customization has been the area of interest for many organizations. Though the opensource CRM is known for its simplicity and ease of use, many people grapple with the extensions, custom views and menus. One of the most common issues pertaining to customization is extending the ListView in different forms of SugarCRM. The task is simple if done by following a step by step guide. Following are the steps you need to follow in order to extend the LlistView query:
1. Create or edit custom/modules/Opportunities/views/view.list.php and add following code,

if(!$current_user->is_admin) // remove this condition if you dont want admin user to view the “Closed Lost” Opportunities.
$this->params[‘custom_where’] = ‘ AND opportunities.sales_stage <> “Closed Lost” ‘;

if (empty($_REQUEST[‘search_form_only’]) || $_REQUEST[‘search_form_only’] == false) {
$this->lv->setup($this->seed, ‘include/ListView/ListViewGeneric.tpl’, $this->where, $this->params);
$savedSearchName = empty($_REQUEST[‘saved_search_select_name’]) ? ” : (‘ – ‘ . $_REQUEST[‘saved_search_select_name’]);
echo $this->lv->display();

Step 2: Refresh list view!

The probable customizations you will see in the query are:

a. Custom_form
b. Custom_where
c. Custom_select
d. Custom_order_by