Adding filters with “And” and “or” in 2.0rc1

Refresh

April 2019

Views

66 time

1

I am having problem in using filters with "And" and "or" clause. Basically i want to get any userstories having text "Mobile" or "Testing"

I am trying like this :

                    _createFilters:function(){
                    var filter = Ext.create('Rally.data.QueryFilter',
                    {
                        property: 'Name',
                        operator: 'contains',
                        value: 'Mobile'
                    }
                );

                    filter = filter.or(Ext.create('Rally.data.QueryFilter',
                    {
                        property: 'Name',
                        operator: 'contains',
                        value: 'Testing'
                    }));

                    return filter.toString();

                },
                _makeDefectsStore:function(ref){
                    Ext.create('Rally.data.WsapiDataStore',{  // will fetch userstories that have defects
                        model: 'User Story',
                        limit: "Infinity",
                        context: {
                            project :'/project/xxxx',
                            projectScopeUp: false,
                            projectScopeDown: true
                        },
                        autoLoad: true,
                        fetch:['FormattedID','Name','Defects','Feature'],
                       filters: [this._createFilters()],
                       scope:this,
                        listeners: {
                            load: this._onAllDefectsLoaded,
                            scope: this
                        }
                    });
                }

Here filter is returning null, otherwise all the userstories are returned without filtering . Please provide suggestion/fix

1 answers

1

Nothing immediately pops out as being incorrect with your filter construction, you might try this simpler version though and see what you get:

Ext.create('Rally.data.WsapiDataStore', {
    model   : 'UserStory',
    filters : Rally.data.QueryFilter.or([{
        property : 'Name',
        operator : 'contains',
        value    : 'Testing'
    },{
        property : 'Name',
        operator : 'contains',
        value    : 'Mobile'
    }])
});