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
  • Hi Neil Conacher 

    I believe you can create a custom filter operators (custom/clients/base/filters/operators/operators.php) and set the operators $empty and $not_empty for date type fields:

    <?PHP

    include 'clients/base/filters/operators/operators.php';

    $viewdefs['base']['filter']['operators']['date']['$empty'] = 'LBL_OPERATOR_EMPTY';

    $viewdefs['base']['filter']['operators']['date']['$not_empty'] = 'LBL_OPERATOR_NOT_EMPTY';

    $viewdefs['base']['filter']['operators']['datetime']['$empty'] = 'LBL_OPERATOR_EMPTY';

    $viewdefs['base']['filter']['operators']['datetime']['$not_empty'] = 'LBL_OPERATOR_NOT_EMPTY';

    $viewdefs['base']['filter']['operators']['datetimecombo']['$empty'] = 'LBL_OPERATOR_EMPTY';

    $viewdefs['base']['filter']['operators']['datetimecombo']['$not_empty'] = 'LBL_OPERATOR_NOT_EMPTY';

    Go to Admin -> Repar -> "Quick Repair and Rebuild" / "Clear Additional Cache" after saving this file.

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hello all...

    Thank you  André Lopes!  That is sooooo handy to look for empty or not empty date fields!  Leaves me wondering why Sugar don't have that by default?

    Like Jairam Madankar we also deployed an addition (below) so we can also filter for a relate field which is empty or not empty. We plan to add text fields (varchar?) to it also.

    - Why?  I wanted to find Contacts where Account is Empty, then do a recalculate values.  I did a report export import but that seemed to not work for populating a text field on contact's with a related lookup formula to the account - but mass update works a treat.

    This is what was added to Andre's code above:

    $viewdefs['base']['filter']['operators']['relate']['$empty'] = 'LBL_OPERATOR_EMPTY';
    $viewdefs['base']['filter']['operators']['relate']['$not_empty'] = 'LBL_OPERATOR_NOT_EMPTY';

    I have also added this comment to the following 'idea':

    Add operator "is empty" on text field filter 

    Thanks again!

Reply
  • Hello all...

    Thank you  André Lopes!  That is sooooo handy to look for empty or not empty date fields!  Leaves me wondering why Sugar don't have that by default?

    Like Jairam Madankar we also deployed an addition (below) so we can also filter for a relate field which is empty or not empty. We plan to add text fields (varchar?) to it also.

    - Why?  I wanted to find Contacts where Account is Empty, then do a recalculate values.  I did a report export import but that seemed to not work for populating a text field on contact's with a related lookup formula to the account - but mass update works a treat.

    This is what was added to Andre's code above:

    $viewdefs['base']['filter']['operators']['relate']['$empty'] = 'LBL_OPERATOR_EMPTY';
    $viewdefs['base']['filter']['operators']['relate']['$not_empty'] = 'LBL_OPERATOR_NOT_EMPTY';

    I have also added this comment to the following 'idea':

    Add operator "is empty" on text field filter 

    Thanks again!

Children
No Data