AnsweredAssumed Answered

Custom filter with date type field not working

Question asked by Felippe Junger on Aug 6, 2019
Latest reply on Aug 8, 2019 by Felippe Junger

Hello guys,

 

I'm having problem with custom filter with date type field.

On server there is a custom filter like that:

 

'filter_definition' => array(
    array(
        'sng_etapa_atendimento_c' => 'negociacao',
    ),
    array(
        '$or' => array(
            array(
                'sng_ag_data_prox_contato_c' => array(
                    '$dateRange' => 'today'
                ),
            ),
            array(
                'sng_atd_dt_prox_contato_c' => array(
                    '$dateRange' => 'today'
                ),
            ),
        ),
    ),
),
'editable'          => false,

This filter works very well on sugar web version but on the mobile one, this filter did not retrieve anything.

So I've tried to customize the filtered-list-view: https://mobiletools.sugarcrm.com/docs/latest/sdk/docs/sdk/tutorial-meetings-list-view.html .

const customization = require('%app.core%/customization.js');

const FilteredListView = require('%app.views%/list/filtered-list-view');

const MeetingsListView = customization.extend(FilteredListView, {

    initialize(options) {
        this._super(options);

        this.collection.filterDef = {
            sng_etapa_atendimento_c: 'negociacao',
            date_modified: {
                $dateRange: 'today',
            },
        };
    },

This example worked very well, using the date_modified field(DateTime type), but when I've tried to use the field 

sng_atd_dt_prox_contato_c(Date type) the filter did not worked. So I created a new custom field 
on instance called dt_prox_contato_apagar_c (DateTime Type), filled the field with today information
and change the filter to:

initialize(options) {
    this._super(options);

    this.collection.filterDef = {
        sng_etapa_atendimento_c: 'negociacao',
        dt_prox_contato_apagar_c: {
            $dateRange: 'today',
        },
    };
},
The filter worked!

My question is: Is there a problem on mobile to filter Date type fields?
Because I need to make the filter on the Date type field...

Outcomes