Filter on empty date in ListView

When building a filter in ListView, the date field filter options do not include Is Empty/Is Not Empty options (as it does in Reports)

Sugar Support have logged this as a defect/enhancement

Does anyone have a way of dealing with this. It is a basic business requirement to list records which don't have a date field completed.

My specific requirement involves a number of date fields so I want to avoid creating a custom calculated field (which would be an option if only one field involved) which I could filter on (eg date present)

Thanks 

Parents
  • You must always check $viewdefs to be not empty and use the "||" operator, not "or". Try this code, it just worked with 10.1:

    require_once 'clients/base/filters/operators/operators.php';
    if (!empty($viewdefs['base']['filter']['operators']))
    {
    	foreach($viewdefs['base']['filter']['operators'] as $key => $view)
    	{
    		if(($key == 'date') || ($key == 'datetime') || ($key == 'datetimecombo'))
    		{
    			$viewdefs['base']['filter']['operators'][$key]['$empty'] = 'LBL_OPERATOR_EMPTY';
    			$viewdefs['base']['filter']['operators'][$key]['$not_empty'] = 'LBL_OPERATOR_NOT_EMPTY';
    		}
    	}
    }

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

Reply
  • You must always check $viewdefs to be not empty and use the "||" operator, not "or". Try this code, it just worked with 10.1:

    require_once 'clients/base/filters/operators/operators.php';
    if (!empty($viewdefs['base']['filter']['operators']))
    {
    	foreach($viewdefs['base']['filter']['operators'] as $key => $view)
    	{
    		if(($key == 'date') || ($key == 'datetime') || ($key == 'datetimecombo'))
    		{
    			$viewdefs['base']['filter']['operators'][$key]['$empty'] = 'LBL_OPERATOR_EMPTY';
    			$viewdefs['base']['filter']['operators'][$key]['$not_empty'] = 'LBL_OPERATOR_NOT_EMPTY';
    		}
    	}
    }

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

Children
No Data