在 SuiteCRM 中按 'logged in user' 排序列表视图

Sort order list view by 'logged in user' in SuiteCRM

删除列表视图中的默认排序顺序并在 SuiteCRM 中按 'Logged in user' 排序。

在custom/modules/Prospects(您的模块)/views/view中添加以下代码list.php

 function listViewProcess() {

    global $current_user; 
    $user_name = $current_user->user_name;
    $id = $current_user->id;
    $this->processSearchForm();

        $this->params['custom_order_by'] = ' ORDER BY FIELD(assigned_user_id, "'.$id.'") DESC';
        $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();
} 

custom_order_by 将被视为二阶字段 所以声明

$ret_array['order_by']=''; 在 include/ListView/ListViewData.php

之前

$main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['inner_join']. $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];

无需自定义include/listView/ListViewDate.php中的代码,只需在custom/modules/(你的模块)/views/view.list.php中添加如下代码即可

    function listViewProcess() {

            global $current_user; 
            $user_name = $current_user->user_name;
            $id = $current_user->id;
            $this->processSearchForm();
                $this->params['overrideOrder']='1';
                $this->params['orderBy']='1';
                $this->params['custom_order_by'] = ' ORDER BY FIELD(accounts.assigned_user_id, "'.$id.'") DESC';
                $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();
        }