首页 > 解决方案 > 在弹出窗口中显示字段为 NULL 的记录

问题描述

select当我们单击子面板内的按钮时,我能够过滤出现的记录。可以通过$initial_filter像这样覆盖值来完成:

public function display($widget_data, $additionalFormFields = null, $nonbutton = false) {
    global $app_strings; $initial_filter = '';
    $initial_filter.='&SOME_FIELD='.urlencode("SOMEVALUE");
}

$_GET当弹出窗口打开时,该初始过滤器将用作参数,因此它将知道要显示哪些记录

现在棘手的部分是我试图弄清楚如何过滤它,以便它显示 SOME_FIELD 为空的记录......我尝试了类似的东西SOME_FIELD=nullSOME_FIELD=false但它不起作用......如果有人可以提出任何建议,将不胜感激。

标签: sugarcrmsuitecrm

解决方案


您将需要修改列表视图查询和数据获取逻辑。查看以下详细信息以获取更多帮助:

仅用于列表视图custom/modules/MODULE_NAME/views/view.list.php

以下是帮助代码:

require_once('include/MVC/View/views/view.list.php');
class MODULE_NAMEViewList extends ViewList {

    function listViewProcess() {
        global $current_user;
        $this->params['custom_where'] = ' AND module_name.name = "test" ';

        parent::listViewProcess();
}

}



对于列表和弹出视图(两者)

您需要更改create_new_list_query实际准备查询的函数内部的逻辑。一些模块已经覆盖它一个 bean 级别(例如,请参阅modules/Leads/Lead.php)。

如果您想以升级安全的方式覆盖它,则在自定义目录中创建一个文件,例如:custom/modules/Leads/Lead.php,然后从核心 bean 类扩展它,如下所示:

<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

require_once('modules/Leads/Lead.php');
class CustomLead extends Lead {

    function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false, $ifListForExport = false)
    { 
        // Code from create_new_list_query in and then modify it accordingly. 
    }
}

在此位置注册新的 bean 类:custom/Extension/application/Ext/Include/custom_leads_class.php注册代码如下所示:

<?php
$objectList['Leads'] = 'Lead';
$beanList['Leads'] = 'CustomLead';
$beanFiles['CustomLead'] = 'custom/modules/Leads/Lead.php';
?>

推荐阅读