Custom ListView Statement

I need to create a custom SQL statement for my listview. I need to use order_by, group_by, where

I assume I can use the function: function create_new_list_query

Could someone provide me with a simple example?

is this for your custom module or core module?

This is for a custom module.

I created a custom Menu and view for this module.

Currently I am using:

<?php if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } //require_once('modules/wo_Work_Orders/wo_Work_OrdersListViewSmarty.php'); require_once('include/MVC/View/views/view.list.php'); class ViewWoodShop extends ViewList { public function __construct() { parent::__construct(); } public function preDisplay() { $this->lv = new ListViewSmarty(); } function processSearchForm(){ $this->where.="assigned_department_c = 'wood_shop'"; } } But I NEED to have Group By "priority_c" (DESC)

Don’t need a lot of stuff

just put this at your main bean file

class list_Listings extends list_Listings_sugar {
	function list_Listings(){	
function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false, $parentbean = null, $singleSelect = false){
global $current_user;
$ret_array = parent::create_new_list_query($order_by, $where, $filter, $params, $show_deleted, $join_type, true, $parentbean, $singleSelect);
$user_id =$current_user->id;
	$user_id =$current_user->reports_to_id;
    	if ( !$return_array )
            return  $ret_array['select'] . $ret_array['from'] . $ret_array['where']. $ret_array['order_by'];
        return $ret_array;

Please explain what you mean by main bean file.

I see the order by but I dont see where I can add Group BY?

a bean file mean a file inside main module folder with same name like for Account module , there is Account.php file.

as this is matter of your custom module, you can put your directly to bean file using above function.

for any additional things, you append your Arrays.


Thank you